watch: {
// 监听路由对象变化(包括 query、params、hash 等)
$route: {
handler(to, from) {
console.log('路由变化(含浏览器后退):', from.path, '→', to.path)
this.$nextTick(() => {
this.init();
})
}
}
},哪里有错误呢
这个是之前dom的结果 , dom并未更新 , 所以执行函数设置属性都会出错
watch: {
// 监听路由对象变化(包括 query、params、hash 等)
$route: {
handler(to, from) {
console.log('路由变化(含浏览器后退):', from.path, '→', to.path)
this.$nextTick(() => {
this.init();
})
}
}
},哪里有错误呢
这个是之前dom的结果 , dom并未更新 , 所以执行函数设置属性都会出错
2 回答5k 阅读✓ 已解决
4 回答4.5k 阅读✓ 已解决
4 回答2k 阅读✓ 已解决
4 回答2.1k 阅读✓ 已解决
3 回答1.8k 阅读✓ 已解决
3 回答4.9k 阅读
2 回答2.6k 阅读✓ 已解决
给 router-view 加个 key,使路由有一点改变就重新加载组件
还有如果像你所写,如果你的路由监控生效了,init 方法应该也会生效,如果你写的是响应式界面,数据更新了界面应该也会更新吧