場景
切換導(dǎo)航用戶/組織id后,i需要刷新所在頁面。
ctrl+f5/window.reload會(huì)頁面刷新,但可以vue內(nèi)部實(shí)現(xiàn)。
image.png
1空白頁
<template>
</template>
<script>
export default {
data() {
return {
}
},
created() {
// 獲取當(dāng)前的路由
let path=this.$route.params.link
//替換為原先路由
this.$router.replace({
path:path
})
}
}
</script>
2 引入公共head所在跳轉(zhuǎn)頁
methods:{
changeOrg(item) {
//設(shè)置本地
localStorage.setItem('curOrg', item.id)
//執(zhí)行store有時(shí)沒觸發(fā)
this.$store.dispatch('update',JSON.parse(JSON.stringify(item)))
// 跳轉(zhuǎn)其他頁面再返回
this.$router.push({
name:'back',
params:{
link:this.$route.path//當(dāng)前路由
}
})
},
}
route.js
{
//全局刷新
path: '/back',
name: 'back',
component: () =>
import ('@/views/空白頁'),
}