1. 首页
  2. 人工智能
  3. 计算广告
  4. vue中全局路由守卫中替代this操作(this.$store/this.$vux)

vue中全局路由守卫中替代this操作(this.$store/this.$vux)

上传者: 2020-11-21 22:36:41上传 PDF文件 31.04KB 热度 15次
全局路由守卫this.$vux.loading.hide()报错,访问不到this 解决办法 申明变量代替this main.js文件方法 router.beforeEach((to, from, next) => { if(vue){ vue.$vux.loading.hide() }else{ } next() }) let vue = new Vue({ el: '#app', router, store, components: { App }, template: '' }) if判断防止第一次初始化报错 或者 let vue = new Vue
下载地址
用户评论