无法访问.beforeEach()中的Buefy组件

耶尔森

我试图从Buefy访问Toast组件,以在每次有人尝试访问仅授权视图时显示错误:

// ...
import { Toast } from 'buefy/dist/components/toast'

router.beforeEach((to, from, next) => {
  // ...
  if (to.matched.some(record => record.meta.requiresAuth)) {
    if (!(store.state.isAuth)) {
      Toast.open({
        message: "Not authorized"
      });
      next({
        path: '/login/',
      })
    } else {
      next()
    }
  } else {
    next()
  }
}

Toast未定义,我确实已经Buefy导入并Vue.use(Buefy)编写了。

我如何解决此问题并在此处访问Toast。提前致谢。

耶尔森

我解决了这个问题。

Vue.prototype.$toast自从加载$ toast方法以来,我得到了Vue.use(Buefy)

感谢您的关注。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章