在App.vue中
1
2
3
4
5
6
7
8 export default {
9 name: 'App',
10 provide: function () {
11 return {
12 reload: this.reload
13 }
14 },
15 data: function () {
16 return {
17 isRouterAlive: true
18 }
19 },
20 methods: {
21 reload: function () {
22 this.isRouterAlive = false;
23 this.$nextTick(function () {
24 this.isRouterAlive = true
25 })
26 }
27 }
28 }
29
然后在需要使用这个方法的的vue组件中注入这个方法
1 data(){},
2 inject:["reload"]
3
4
5 //然后在你想要使用的地方 使用就可以了
6 this.reload()
转自:https://www.jianshu.com/p/26d37a1d5b73
标签:function,vue,return,isRouterAlive,reload,刷新,true,页面
来源: https://www.cnblogs.com/ronle/p/10852684.html