我试图从Buefy访问Toast组件,以便每次有人尝试访问auth视图时都显示错误:
// ...
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)。
我怎样才能解决这个问题,并在这里获得烤面包。提前谢谢。
发布于 2018-09-21 17:37:36
我解决了这个问题。
我从Vue.prototype.$toast获得了Vue.prototype.$toast方法,因为我用Vue.use(Buefy)加载了它。
谢谢大家的关注。
https://stackoverflow.com/questions/52448455
复制相似问题