刷新頁面store肯定是會丟的,
那不刷新頁面store會丟嗎? 我們分情況說一下
1、hash 路由模式
使用 window.location.href 和 this.$router.push 或 replace
不管使用這三種方式的哪一種 store 都不會丟
2、history路由
this.router.replace store 不丟
window.location.href 頁面刷新 store 丟
總結(jié): 只有路由模式是history 且用location.href跳轉(zhuǎn)路由的時(shí)候 store會丟
補(bǔ)充: 組件懶加載的三種方式的效果一樣 : 都是加載組件的時(shí)候才加載對應(yīng)的依賴js 切換回之前的tab js有緩存 不會重新加載