【发布时间】:2021-02-22 15:35:11
【问题描述】:
我正在使用$vs.notify 来显示来自数据库的消息。所以想到在actions.js中使用它。但得到错误TypeError: Cannot read property 'notify' of undefined。有什么方法可以在 action.js 文件中使用它。
使用的代码在这里:
addTag({
commit
}, tag) {
return new Promise((resolve, reject) => {
Vue.prototype.$http.post('/tags/add/', {
tag
})
.then((response) => {
commit('ADD_TAG', Object.assign(response.data.data[0]))
Vue.prototype.$vs.notify({
title: 'Success',
text: `tag-${response.data.data[0].name} added suceesfully`,
iconPack: 'feather',
icon: 'icon-alert-circle',
color: 'success'
})
resolve(response)
})
.catch((error) => {
reject(error)
})
})
}
【问题讨论】:
-
$vs.notify单独不起作用?