在VUE中通过provide/reject的方式刷新当前页面
首先在APP.VUE中的data定义一个变量,
isRouterAlive: true,
然后给routerview加上v-if属性
<router-view v-if="isRouterAlive"></router-view>
再在methods里加上刷新的方法,
reload () {
this.isRouterAlive = false
this.$nextTick(function() {
this.isRouterAlive = true
})
}
最后把这个方法provide出去
provide () {
return {
reload: this.reload
}
}
这样APP.VUE里的设置就完成了,接下来是需要有刷新功能的页面:
注入方法
inject: ["reload"],
在需要刷新的地方调用即可
this.reload();

浙公网安备 33010602011771号