1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| <template>
| <div id="app">
| <router-view v-if="isRouterAlive"></router-view>
| </div>
| </template>
| <script>
| export default {
| name: 'App',
| provide () { //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。
| return {
| reload: this.reload
| }
| },
| data() {
| return{
| isRouterAlive: true
| }
| },
| methods: {
| reload () {
| this.isRouterAlive = false;
| this.$nextTick(function () {
| this.isRouterAlive = true; //再打开
| })
| }
| }
| }
| </script>
|
|