Javascript 当我尝试使用emailjs:uncaughtreferenceerror:sendMail未定义emailjs时,我收到thsi错误
我对使用emailjs发送电子邮件有一个问题,但它不起作用。注意:这是我第一次使用javascript发送电子邮件。我用python尝试过一次,当然,我在stackover flow的帮助下管理了它 js htmlJavascript 当我尝试使用emailjs:uncaughtreferenceerror:sendMail未定义emailjs时,我收到thsi错误,javascript,html,email,Javascript,Html,Email,我对使用emailjs发送电子邮件有一个问题,但它不起作用。注意:这是我第一次使用javascript发送电子邮件。我用python尝试过一次,当然,我在stackover flow的帮助下管理了它 js html 运输方式 名称 地址 免费接送 整个星期 名字 地址* 请输入您的送货地址。 免费快递(仅适用于拉巴特地区) 星期一至星期日星期二除外 姓 地址2* 图像 品名 价格 总计 $0.00 萨姆比特 我认为问题出在头脑中,所以这里是head的html代码,也许有一个比我更有经验的人
运输方式
名称
地址
免费接送
整个星期
名字
地址*
请输入您的送货地址。
免费快递(仅适用于拉巴特地区)
星期一至星期日星期二除外
姓
地址2*
图像
品名
价格
总计
$0.00
萨姆比特
我认为问题出在头脑中,所以这里是head的html代码,也许有一个比我更有经验的人可以帮助我解决问题,我真的很抱歉有太多的问题,但这就是我学习的方式,也许有一天我也可以帮助别人:)
Freshshop-电子商务引导4 HTML模板
(功能(){
emailjs.init(“用户_kYW9KXIGDrTbr7OrZS16g”);
})();
您没有调用sendMail()函数。还要注意,onclick属性不是camelcase。
在你的情况下,下面这一行应该有用
<button onclick="sendMail()" class= "sumbit type" type="submit">Sumbit</button>
Sumbit
ty谢谢您的时间,但仍然没有。我想点击并没有指向控制台中的custom.js文件。我收到这个错误VM21943 shop.html:1171 Uncaught ReferenceError:sendMail没有在htmlButtoneElement.onclick(VM21943 shop.html:1171)中定义我通常会得到custom.js文件,但现在它出现了新的错误,我不知道为什么需要将custom.js导入到使用该函数的html文件中。只要html文件和js文件处于同一级别,您就可以通过
来实现。或者,如果你同意在html文件中添加函数,你可以通过来完成,我已经在头脑中这样做了,但是我不知道为什么它没有提到它(在头脑中我像这样做了>)
<section id="sectionone"
form method = "post" class ="hidesection" >
<div class="col-sm-6 col-lg-6 mb-3">
<div class="row">
<div class="col-md-12 col-lg-12">
<table class="table">
<thead>
<tr>
<th>Shipping Method</th>
<th>Name</th>
<th>Adress</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="custom-control custom-radio">
<input id="shippingOption1" name="shipping-option" class="custom-control-input" checked="checked" type="radio">
<label class="custom-control-label" for="shippingOption1">Pickup</label> <span class="float-right font-weight-bold">FREE</span> </div>
<div class="ml-4 mb-2 small">All week</div></td>
<td>
<div class="form-group col-md-6">
<label for="InputName" class="mb-0">First Name</label>
<input type="text" class="form-control" id="InputName" placeholder="First Name"> </div></td>
<td> <div class="mb-3">
<label for="address">Address *</label>
<input type="text" class="form-control" id="address" placeholder="" required>
<div class="invalid-feedback"> Please enter your shipping address. </div>
</div></td></tr>
<tr>
<td>
<div class="custom-control custom-radio">
<input id="shippingOption2" name="shipping-option" class="custom-control-input" type="radio">
<label class="custom-control-label" for="shippingOption2">Express Delivery</label> <span class="float-right font-weight-bold">Free (Only To Rabat Area)</span> </div>
<div class="ml-4 mb-2 small">Monday To sunday Exept Tuesday</div>
</td><td><div class="form-group col-md-6">
<label for="InputLastname" class="mb-0">Last Name</label>
<input type="text" class="form-control" id="InputLastname" placeholder="Last Name"> </div>
</td><td>
<div class="mb-3">
<label for="address2">Address 2 *</label>
<input type="text" class="form-control" id="address2" placeholder=""> </div></td></tr>
</tbody></table>
</div></div></div>
<div class="cart-box-main">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="table-main table-responsive">
<table class="table">
<thead>
<tr>
<th>Images</th>
<th>Product Name</th>
<th>Price</th>
</tr>
</thead>
<tbody class ="cart-items">
<tr class = "removebut">
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row my-5">
<div class="col-lg-8 col-sm-12"></div>
<div class="col-lg-4 col-sm-12">
<div class="order-box">
<div class="d-flex gr-total">
<h5>Grand Total</h5>
<div class="ml-auto h5"> <span id="total" class="d-flex-gr-total">$0.00</span></div>
</div>
<hr> </div>
</div>
<button onClick="sendMail" class= "sumbit type" type="submit">Sumbit</button>
</div>
</div>
</div>
<html lang="en">
<!-- Basic -->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Mobile Metas -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Site Metas -->
<title>Freshshop - Ecommerce Bootstrap 4 HTML Template</title>
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="author" content="">
<!-- Site Icons -->
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Site CSS -->
<link rel="stylesheet" href="css/style.css">
<!-- Responsive CSS -->
<link rel="stylesheet" href="css/responsive.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="css/custom.css">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/emailjs-com@2/dist/email.min.js"></script>
<script type="text/javascript">
(function() {
emailjs.init("user_kYW9KXIGDrTbr7OrZS16g");
})();
</script>
<button onclick="sendMail()" class= "sumbit type" type="submit">Sumbit</button>