vue跳轉(zhuǎn)當(dāng)前頁(yè)面頁(yè)面不刷新,導(dǎo)致切換角色的時(shí)候有些權(quán)限無(wú)法更新解決方法:
1.router.go(0) 頁(yè)面刷新
- window.open(path) 頁(yè)面刷新
但是以上解決方法都會(huì)存在閃屏的情況拦赠,用戶體驗(yàn)感很差
3 跳轉(zhuǎn)到空白頁(yè)面,再立即跳轉(zhuǎn)回去韧掩。體驗(yàn)感較好〗颜。空白頁(yè)面的具體代碼如下
<template>
<div class="empty"></div>
</template>
<script>
export default {
name:"emptypage",
data(){
return{
nextPagePath:''
}
},
beforeRouteEnter(to,from,next){
console.log('beforRouteEnter')
console.log(from) // 結(jié)果為undefined疗锐,因?yàn)樵趫?zhí)行beforRouteEnter時(shí)候,組件還沒(méi)有被創(chuàng)建出來(lái)费彼;先執(zhí)行beforRouteEnter滑臊,再執(zhí)行beforeCreate
next((vm)=>{ //參數(shù)vm就是當(dāng)前組件的實(shí)例。
vm.$router.push(from.path)
})
},
created(){
}
}
</script>
<style lang="less" scoped>
.empty{
width: 100%;
height: 80vh;
}
</style>