一、app.vue代码如下
<template>
<div id="app">
<router-view v-if="isRouterAlive" />
</div>
</template>
<script>
export default {
name: "App",
provide (){
return {
reload:this.reload
}
},
data() {
return {
width: "",
CurrentPage:'',
isRouterAlive:true
};
},
created() {
this.CurrentPage = this.$route.path;
this.width = document.body.clientWidth;
},
methods:{
reload (){
this.isRouterAlive = false
this.$nextTick(function(){
this.isRouterAlive = true
})
}
},
computed: {
key() {
return this.$route.path;
},
},
};
</script>
比照图片复制粘贴即可
二、 在需要刷新的页面,注册方法
inject:['reload'],
三、在事件里直接使用即可
this.reload()
照图复制,用到就是赚到