ReferenceError :(函数)未定义

时间:2020-10-28 17:16:27

标签: javascript function vue.js 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"});
    }}}

1 个答案:

答案 0 :(得分:0)

您缺少此绑定。将doNotification()更改为this.doNotification()