我正在尝试实现一个电子邮件api,我已经得到了一些代码。虽然我不知道该放在哪里。目前,我只是收到错误与它。
export default class Contact extends Component {
render() {
return(
<script src="https://smtpjs.com/v2/smtp.js">
Email.send("from@you.com",
"to@them.com",
"This is a subject",
"this is the body",
"smtp.yourisp.com",
"username",
"password");
</script>
在react-native中不能有script标记。br>script标记不适用于react或react本机项目。该标记用于在htmlbr中定义客户端脚本(JavaScript)。您可以使用已经为react-native创建的库来发送电子邮件(如react-native-mail)
将其放入
<script src="https://smtpjs.com/v2/smtp.js"></script>
然后使用组件中的代码:
export default class Contact extends Component {
render() {
window.Email.send("from@you.com", "to@them.com", "This is a subject", "this is the body", "smtp.yourisp.com", "username", "password");
return (<div>Done</div>);
}
// ...
}