Javascript 未捕获类型错误:无法读取属性';发送';未定义的

Javascript 未捕获类型错误:无法读取属性';发送';未定义的,javascript,reactjs,dom-events,Javascript,Reactjs,Dom Events,我有一个表单通过emailJS包添加到我的React应用程序中 这是我的代码: import React from 'react'; import{ init } from 'emailjs-com'; init("user_ID"); class Contact extends React.Component { constructor(props) { super(props); this.state = { feedback: '', name:

我有一个表单通过emailJS包添加到我的React应用程序中

这是我的代码:

import React from 'react';
import{ init } from 'emailjs-com';
init("user_ID");


class Contact extends React.Component {
  constructor(props) {
    super(props);
    this.state = { feedback: '', name: 'Name', email: 'email@gmail.com' };
    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  render() {
    return (
    <form className="test-mailing">
        <h1>Let's see if it works</h1>
        <div>
        <textarea
            id="test-mailing"
            name="test-mailing"
            onChange={this.handleChange}
            placeholder="Post some lorem ipsum here"
            required
            value={this.state.feedback}
            style={{width: '100%', height: '150px'}}
        />
        </div>
        <input type="button" value="Submit" className="btn btn--submit" onClick={this.handleSubmit} />
    </form>
    )
  }

  handleChange(event) {
    this.setState({feedback: event.target.value})
  }

  handleSubmit (event) {
    const templateId = 'template_nbma07k';
    this.sendFeedback(templateId, {message_html: this.state.feedback, from_name: this.state.name, reply_to: this.state.email})

    }

    sendFeedback (templateId,variables) {
      
    window.emailjs.send(
      'service_ID',templateId,
      variables
      ).then(res => {
        console.log('Email successfully sent!')
      })
      // Handle errors here however you like, or use a React error boundary
      .catch(err => console.error('Oh well, you failed. Here some thoughts on the error that occured:', err))
    }
  }
从“React”导入React;
从“emailjs com”导入{init};
初始化(“用户标识”);
类Contact扩展了React.Component{
建造师(道具){
超级(道具);
this.state={反馈:“”,名称:'name',电子邮件:'email@gmail.com' };
this.handleChange=this.handleChange.bind(this);
this.handleSubmit=this.handleSubmit.bind(this);
}
render(){
返回(
让我们看看它是否有效
)
}
手变(活动){
this.setState({反馈:event.target.value})
}
handleSubmit(事件){
const templateId='template_nbma07k';
this.sendFeedback(templateId,{message\u html:this.state.feedback,from\u name:this.state.name,reply\u to:this.state.email})
}
sendFeedback(模板ID、变量){
window.emailjs.send(
“服务ID”,模板ID,
变量
)。然后(res=>{
console.log('电子邮件已成功发送!')
})
//在此处处理错误,或者使用React错误边界
.catch(err=>console.error('哦,你失败了。下面是对发生的错误的一些看法:',err))
}
}
单击submit后,我得到主题中描述的错误。这似乎与我试图在window.emailjs.send上发送的参数有关,但我在emailjs端已经做好了所有设置

有什么想法吗


导出默认联系人

阅读。。。在“Angular X/VueJS/ReactJS”一节中,您应该从“emailjs com”导入emailjs和
emailjs.send(..
谢谢@Bravo,现在更好了,但是由于我从顶部删除了用户ID,现在控制台中出现了这个错误:
index.js:1哦,你失败了。下面是对发生错误的一些想法:EmailJSResponseStatus{status:400,text:用户ID是必需的。要查找此ID,请访问https://dashboard.emailjs.com/admin/integration“}
。不知道应该在函数中的何处添加ID?那么,您仍然调用了init吗?我意识到init是缺少的,所以对于关注此问题的人:
从'emailjs com'导入emailjs;导入{init}”从“emailjs com”;
这些是重要信息谢谢@T.J.Crowder我意识到,我认为实际问题中存在错误,因此我感到困惑。我从未想过问题是错的。谢谢