javascript - ReferenceError:(函数)未定义
问题描述
我试图在成功的承诺上显示弹出通知,但我不断收到“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"});
}}}
解决方案
您缺少此绑定。更改doNotification()
为this.doNotification()
推荐阅读
- keras - Keras 输入层大小
- html - 使用 `#lang scribble/html` 编译 scribble 文档时遇到问题
- javascript - 获取从提供的 ISO 日期到当前月份和年份的所有月份和年份
- java - Java中的正否定
- reactjs - 在真正需要使用函数`act`时使用@testing-library/React?
- google-ads-api - Google 广告 API 已关闭
- python - Python使用currencycoverter或其他动态源将excel列与另一列中的货币转换
- c# - 是否有 Xamarin 导航的替代方案?
- javascript - 后视解决方法?
- c# - 如何为内存中的指针添加值?