使用甜美警报吐司进行错误处理VUEX
我已经在项目上安装了Sweet Alert
。 现在,我想在vuex Action
中使用它,但它不起作用。
update({ commit, dispatch }, data) {
return new Promise(async (resolve, reject) => {
try {
const res = await update(data);
resolve(res.data)
this.app.$toast('this is a test toas', {
title: 'Test'
})
} catch (err) {
this.app.$toast('this is a test toas', {
title: 'Test'
})
reject(err.response);
}
})
},
它在组件中正常工作,但我无法使用this.app。$ toast
访问它。
I have installed sweet alert
on my project.
Now i want to use it in Vuex actions
but it does not work.
update({ commit, dispatch }, data) {
return new Promise(async (resolve, reject) => {
try {
const res = await update(data);
resolve(res.data)
this.app.$toast('this is a test toas', {
title: 'Test'
})
} catch (err) {
this.app.$toast('this is a test toas', {
title: 'Test'
})
reject(err.response);
}
})
},
It works fine in components but i can not access it with this.app.$toast
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$ TOAST仅在
component
范围vuex
中可用,我以前有这样的问题,我将其作为参考参数传递给了吐司。从组件调用
update
方法时将此引用传递给The $toast is only available in
component
Scope notvuex
, I had an issue like that before and I passed this as a reference parameter to toast.while calling the
update
method from component pass this reference as