我正在尝试在成功的诺言中显示弹出通知,但我不断收到“ ReferenceError: doNotification未定义。”。如果我在html中单击按钮时触发了doNotification,则可以正常运行。 我的电子邮件功能也可以正常工作,因为console.log将适当的参数输出到控制台。我不确定为什么从我的电子邮件功能中调用doNotification时会出现此错误?
export default {
methods: {
sendEmail: (e) => {
emailjs.sendForm('gmail', 'template', e.target, 'user')
.then((result) => {
console.log('SUCCESS!', result.status, result.text);
doNotification();
}, (error) => {
console.log('FAILED...', error);
});
e.target.reset();
},
doNotification() {
this.$toast.success("Your message has been sent!", {
position: "bottom-right"});
}}}
答案 0 :(得分:0)
您缺少此绑定。将doNotification()
更改为this.doNotification()