1.強制更新,當數據改變了而頁面沒有改變
this.$set()
this.$forceUpdate()
this.$set()
this.$forceUpdate()
2.watch監聽路由,當路由發生變化時,頁面沒有刷新,可以監聽他的路由,當路由發生變化時,刷新頁面或者觸發動作,使得整個頁面刷新
watch: {
$route: {
handler(newVal, oldVal) {
if (newVal.query.code !== oldVal.query.code)
或者
newVal.params.id !== odl.params.id
{
//調用組價
// this.$emit("");
//執行函數
//this.bindwx();
}
}
}
}
子路由觸發父路由的方法,如果有多層路由,需要由子路由發出動作再一層一層的傳上去,
如孫子路由 this.$emit("updatekeyFn");
<view-router @updatekeyFn="updatekeyFn()"/>
<view-router @updatekeyFn="updatekeyFn()"/>