我想发送一个带有两个参数的EmailJs,分别是来自表单的电子邮件和来自本地存储(并通过.toString()转换为字符串)的let toysList。我怎样才能做到这一点?我知道如何连接电子邮件,因为它处于表单中,但是我不知道我应该在哪里放置一个是变量的toysList。
import React from "react";
import emailjs from "emailjs-com";
let toysList = window.JSON.parse(localStorage.getItem("cart")).toString();
function ClientSubmit() {
function sendEmail(e) {
e.preventDefault();
emailjs
.sendForm(
"...",
"...",
e.target,
"..."
)
.then(
(result) => {
console.log(result.text);
},
(error) => {
console.log(error.text);
}
);
e.target.reset();
alert(
"Email send successfully!"
);
}
return (
<div>
<h3>Give us your mail and we will give you the price of the items</h3>
<form onSubmit={sendEmail}>
<div className="col-4">
<label htmlFor="email">Email</label>
<input
type="email"
className="form-control"
name="email"
placeholder="email@example.com"
/>
</div>
<div className="mb-3 col-2 ">
<input
type="submit"
className="btn btn-primary"
value="Send"
></input>
</div>
</form>
</div>
);
}