【发布时间】:2019-07-31 18:38:56
【问题描述】:
我想做一个基于vue-notification组件的消息传递全局函数
我可以从所需的组件调用一个简单的警报
notification.js
export function notifAlert(message) {
alert(message)
}
在 text.vue 页面中
import { notifAlert } from '@/utils/notification'
export default {
...
methods: {
onButtonClick() {
notifAlert('1123');
}
}
}
但我不知道如何连接 vue-notification 以将它们也称为简单消息
notification.js
import VueNotifications from "vue-notifications";
export function notifAlert(messageText) {
notifications: {
showSuccessMsg(): {
type: VueNotifications.types.success,
title: "Success",
message: messageText
},
showInfoMsg: { ... },
showWarnMsg: { ... },
showErrorMsg: { ... },
}
}
以及如何在方法中调用showSuccessMsg(文本)等?
【问题讨论】:
标签: javascript node.js vue.js