
正文
vue刷新本页面
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
顶层app.vue页面
<template>
<div id="app">
<router-view v-if="isRouterAlive"></router-view>
</div>
</template>
<script>
export default {
name: 'App',
provide() {
return {
reload: this.reload
}
},
data() {
return {
isRouterAlive: true
}
},
methods: {
reload() {
this.isRouterAlive = false
this.$nextTick(() => (this.isRouterAlive = true))
}
}
}</script>
要刷新的页面代码
export default {
inject: ['reload'],
data() {
return { }
},
methods: {
handleReload(){
this.reload();
}
}, }
就这样,可以愉快的刷新页面了。此刷新并不会改变vuex状态。






