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