原理:watch监听 原理是监听模式 下的新旧数据改变 他是2个条件语句 所以会执行2次
解决方案:使用锁的概念
data() {
return {
isGetRoute:false
}
},
watch: {
$route(route) {
if (this.isGetRoute) {
this.isGetRoute = !this.isGetRoute
console.log(this.isGetRoute,'this.isGetRoute')
store.commit('permission/getCurrentPagePermission', route.path)
console.log(store.state.permission.currentPagePermission,'当前路由下的权限')
}
}
vue watch监听执行2次
最新推荐文章于 2024-05-23 19:21:07 发布