真实的业务场景中,这种情况很多。比如
页面切换时不会触发mounted钩子,解决方法在router-view上加上一个唯一的key,来保证路由切换时都会重新渲染触发钩子了。
: computed: { key() { return this.$route.name !== undefined? this.$route.name + +new Date(): this.$route + +new Date() }}复制代码
前端菜鸟写笔记(非原创)欢迎点赞。
本文共 247 字,大约阅读时间需要 1 分钟。
真实的业务场景中,这种情况很多。比如
页面切换时不会触发mounted钩子,解决方法在router-view上加上一个唯一的key,来保证路由切换时都会重新渲染触发钩子了。
: computed: { key() { return this.$route.name !== undefined? this.$route.name + +new Date(): this.$route + +new Date() }}复制代码
前端菜鸟写笔记(非原创)欢迎点赞。
转载地址:http://rpeal.baihongyu.com/