sessionStorage可共享状况和localStorage

一、不一样浏览器没法共享localStorage和sessionStorage的值。web

二、相同浏览器下,而且是同源窗口(协议、域名、端口一致),不一样页面能够共享localStorage值,经过跳转的页面能够共享sessionStorage值。浏览器

三、关于sessionStorage,一般说sessionStorage关闭页面即消失,可是经过跳转的页面能够共享sessionStorage值,跳转有多种方式:session

    (1)  <a href="同源页面" target="_self">跳转</a>    //原窗口
    (2) <a href="同源页面" target="_blank">跳转</a>  //新开窗口
    (3) window.location.href = '同源页面'      //原窗口
    (4) window.location.replace('同源页面')   //原窗口
    (5) window.open('同源页面')       //新开窗口
    (6) this.$router.push({path: '同源页面'})   //经过路由跳转共享值
 
app端经过原生方法更换webView实现跳转,这种方式不能共享sessionStorage,原窗口跳转的页面传递sessionStorage,改变存储值会相互影响,新开窗口跳转方式传递sessionStorage,改变存储值互不影响。
相关文章
相关标签/搜索