例如:name值改变重新请求接口,页面没有更新
localhost:8088/#/index?name=Susan
localhost:8088/#/index?name=Marry
解决:在 app.vue中添加 key:
<div id="app" :key="appKey">
<router-view v-if="isRouterAlive"></router-view>
</div>
data: function () {
return {
isRouterAlive: true,
appKey:1,
}
},
watch:{
'$route':function(newUrl,oldUrl){
this.appKey=new Date().getTime();
}
},
添加了Key值,带参改变后,页面视图也会重新渲染
网友评论