[英]How can I use an external script in my vue methods
When a User registers i need to send them an confirmation email using vue.js. 用户注册后,我需要使用vue.js向他们发送确认电子邮件。
I want to use this scrip provided by https://www.smtpjs.com/ How can i make use of this "Email.send" Method within my vue.js application 我想使用https://www.smtpjs.com/提供的脚本,如何在vue.js应用程序中使用此“ Email.send”方法
<script src="https://smtpjs.com/v3/smtp.js">
</script>
Email.send({
Host : "smtp.yourisp.com",
Username : "username",
Password : "password",
To : 'them@website.com',
From : "you@isp.com",
Subject : "This is the subject",
Body : "And this is the body"
}).then(
message => alert(message)
);
I want it to be like 我希望它像
export default {
name: 'landing',
data () {
return {
component: null
}
},
methods: {
sendEmail(){
Email.send({
Host : "smtp.yourisp.com",
Username : "username",
Password : "password",
To : 'them@website.com',
From : "you@isp.com",
Subject : "This is the subject",
Body : "And this is the body"
}).then(
message => alert(message)
);
}
}
}
The script must have an export, so you could download the script and modify it like this: 该脚本必须具有导出功能,因此您可以下载脚本并进行如下修改:
export var Email = {
... code ...
};
export default Email;
Then in your component, you import it like this: 然后在您的组件中,按如下所示导入它:
import Email from './smtp.js';
With that you should be able to access its functions. 这样,您应该能够访问其功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.