App.vue
<template>
<div id="app">
<router-view v-if="isFresh" />
</div>
<template>
<script>
name: "app",
provide() {
return {
reloadApp: this.reloadApp
}
},
data() {
return {
isFresh: true
}
},
method: {
reloadApp() {
this.isFresh = false
this.nextTick(()=>{
this.isFresh = true
})
}
}
</script>
Child.vue
<template>
<div id="child">
<button @click="reloadApp" />
</div>
<template>
<script>
name: "child",
inject: ["reloadApp"]
</script>
网友评论