vue 刷新当前页面并且替换参数
1.app.vue
<template>
<div id="app">
<Header></Header>
<router-view v-if="isRouterAlive"/>
<Footer></Footer>
<GoTop></GoTop>
</div>
</template>
<script>
export default {
name: 'App',
provide (){
return {
reload: this.reload
}
},
data(){
return {
isRouterAlive: true
}
},
methods:{
reload(){
this.isRouterAlive = false;
this.$nextTick(function(){
this.isRouterAlive = true;
})
}
}
}
</script>
<style>
</style>
2.当前需要刷新的页面
inject: ["reload"],
methods: {
toNewsDetail(i, item) {
var that = this;
this.$router.replace(
{
name: "newsDetail",
params: { id: item.id, type: item.type },
},
() => {
that.reload();
}
);
},
},