刚入门vue,发现很多坑,对很多框架兼容性不太友好,比如layui等

每次删除相关信息,更新相关信息,不会主动刷新当前页面内容,只能手动刷新

第一步,我们在跟组件理由设置一个参数,用来判断是否需要刷新

<router-view v-if = 'isRouterAlive'></router-view>

在跟组件添加
provide(){
return{
reload:this.reload
}
},
data(){
return {
currentUser_name:localStorage.getItem('currentUser_name'),
isRouterAlive:true, //要记得返回这个,不然的话,路由都不见了
}
},
注册一个reload方法
reload(){
this.isRouterAlive = false
this.$nextTick(function () {
this.isRouterAlive = true
})
},
最后在子组件里头进行注册
inject:['reload'],
使用的时候调用
this.reload();就可以了




相关文章:

  • 2021-12-20
  • 2021-08-15
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2021-06-22
  • 2021-11-30
  • 2021-12-05
相关资源
相似解决方案