Vue路由刷新
1.App.vue代码
<template>
<div id="app">
<router-view v-if="isRouterAlive"></router-view>
</div>
</template>
<script>
export default {
provide() {
return {
reload: this.reload,
}
},
data() {
return {
isRouterAlive: false
}
},
methods: {
reload() {
this.isRouterAlive = false
this.$nextTick(function () {
this.isRouterAlive = true
})
}
},
}
</script>
<style>
#app {
width: 100%;
height: 100%;
}
</style>
2.调用的js
<script>
export default {
inject: ['reload'], //注入
},
methods: {
reload:(){
this.reload(); //调用刷新
}
}
</script>