javascript Vue 发送邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49687977/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 08:43:14  来源:igfitidea点击:

Vue sending email

javascriptvue.js

提问by Wojtar

I have a problem. I want to put a contact form on the page, but I do not know how to do it in the Vue. I wanted to do it normally as jquery, php, but it does not work in Vue. Does anyone have an idea what I can do?

我有个问题。我想在页面上放一个联系表,但是我不知道在Vue.js中怎么做。我想像 jquery、php 一样正常地做,但它在 Vue 中不起作用。有谁知道我能做什么?

回答by gillyhl

You would ideally send email data (to, message body - html escaped of course) as a request to a backend end point and send from there. You can use Vue's HTTP resource to send the request: https://github.com/pagekit/vue-resource

理想情况下,您可以将电子邮件数据(发送到消息正文 - 当然是 html 转义)作为对后端端点的请求发送并从那里发送。可以使用Vue的HTTP资源发送请求:https: //github.com/pagekit/vue-resource

But sending an email directly from Vue isn't possible.

但是直接从 Vue 发送电子邮件是不可能的。

回答by Niels de Bruin

Vue is a View (hence the name) library, meant for describing your View layer i.e. how your application looks. Such logic as sending an email would for one be dependent on Javascript itself and not on Vue.

Vue 是一个视图(因此得名)库,用于描述您的视图层,即您的应用程序的外观。发送电子邮件之类的逻辑将依赖于 Javascript 本身而不是 Vue。

However it is not possibleto send an email from Javascript in the browser. Instead you'd need to build a backend which can send an email for you, or you could call the user's email client, both described here.

但是,无法在浏览器中从 Javascript 发送电子邮件。相反,您需要构建一个可以为您发送电子邮件的后端,或者您可以调用用户的电子邮件客户端,两者都在此处描述