vue頁面更新數據


在App.vue中

 1 <template>
 2   <div id="app">
 3     <router-view v-if="isRouterAlive"/>
 4   </div>
 5 </template>
 6 
 7 <script>
 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 </script>

然后在需要使用這個方法的的vue組件中注入這個方法

1 data(){},
2 inject:["reload"]
3 
4 
5 //然后在你想要使用的地方 使用就可以了
6 this.reload()

轉自:https://www.jianshu.com/p/26d37a1d5b73


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM