在Vue全局路由守卫中,如何替换this.$store或this.$router的this操作?
- 内容介绍
- 文章标签
- 相关推荐
本文共计319个文字,预计阅读时间需要2分钟。
全局路由守卫中,`this.$vux.loading.hide()` 报错,无法访问 `this`。解决方法:明确变量替代 `this`,修改 `main.js` 文件方法,使用 `router.beforeEach((to, from, next)=> { if (vue) { vue.$vux.loading.hide() } else { } next() })`。
本文共计319个文字,预计阅读时间需要2分钟。
全局路由守卫中,`this.$vux.loading.hide()` 报错,无法访问 `this`。解决方法:明确变量替代 `this`,修改 `main.js` 文件方法,使用 `router.beforeEach((to, from, next)=> { if (vue) { vue.$vux.loading.hide() } else { } next() })`。

