问题描述
当用户使用他们的电子邮件注册时,我正在尝试使用一个不错的电子邮件模板,我正在使用 express & node mailer 来完成此操作。以前我的代码看起来像:
"Hello," +
user.username +
",\n\n" +
"Please complete your registration by clicking the link:
\nhttp://" + req.headers.host + "/confirmation/" + user.username + "/" + token.token +
"\n\nThank you!\n"
const output = ` <a href="${req.headers.host} + "/confirmation/" + ${user.username} + "/" + ${token.token}" `
但这不起作用,电子邮件内部的 href
上没有 <a>
。
我一定遗漏了一些非常基本的东西...感谢您的关注 =)
解决方法
使用 `` 你不需要用 +
连接字符串,所以它应该是这样的:
const output = `<a href="${req.headers.host}/confirmation/${user.username}/${token.token}"></a>`