首页上有个按钮切换:
this.$router.push({ path: "/cutLogin" });
然后我在cutLogin页面点击跳到首页(我要切换到首页并刷新整个页面获取某些权限,provide /inject 这不行。)
this.$router.push({ path: "/index"})
let aboutRoute = this.$route.fullPath
if (aboutRoute == '/index') {
window.location.reload(true);
}
这样写跳转后是刷新首页页面,但有问题,有时候aboutRoute 获取到的不是/index,是/cutLogin,这是为啥?
用window.location.href
重新加载data或者你想要刷新属性所在的生命周期,但是我推荐使用watch监听,监听到某个事件或值页面会重新加载生命周期
使用keep-alive试试,参考如下链接
https://www.cnblogs.com/ralapgao/p/11121847.html