在Vue全局路由守卫中,如何替换this.$store或this.$router的this操作?

更新于
2026-10-02 01:32:23
1阅读来源:SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计319个文字,预计阅读时间需要2分钟。

在Vue全局路由守卫中,如何替换this.$store或this.$router的this操作?

全局路由守卫中,`this.$vux.loading.hide()` 报错,无法访问 `this`。解决方法:明确变量替代 `this`,修改 `main.js` 文件方法,使用 `router.beforeEach((to, from, next)=> { if (vue) { vue.$vux.loading.hide() } else { } next() })`。

阅读全文

本文共计319个文字,预计阅读时间需要2分钟。

在Vue全局路由守卫中,如何替换this.$store或this.$router的this操作?

全局路由守卫中,`this.$vux.loading.hide()` 报错,无法访问 `this`。解决方法:明确变量替代 `this`,修改 `main.js` 文件方法,使用 `router.beforeEach((to, from, next)=> { if (vue) { vue.$vux.loading.hide() } else { } next() })`。

阅读全文