WhatsApp按钮中的点击功能



我在向数据库发送输入的订单按钮中有onclick函数,在修改按钮(将其连接到WhatsApp而不是数据库(后,onclick函数已停止工作。。。我需要onclick函数才能工作。

<form className="orderForm">
<div className="form-group">
<div className="whatsapp" style="margin-top: 20px;">
<button
className="btn-primary"
onClick="reportConversion(event.target)"
type="submit"
style="height:70px;width: 100%;"
>
<img
src="wat.png"
style="width: 36px;height: 36px; position: absolute; margin-left: -40px;margin-top: -10px;"
/>
<a href="https://wa.me/......" style="color: white;font-weight: 600; font-size: 18px;">
...text...
</a>
</button>
</div>
</div>
</form>

使用Promse是一个很好的解决方案,但reportConversion的返回是未知的,也不确定我们是否可以修改它?

无论如何,由于我们有链接优先级,这个解决方案可能会很合适。

注意:请记住将<button>类型从submit更改为button,并从内部删除链接。

function reportConversionWrapper(target) {
reportConversion(target);
setTimeout( function() {
window.location.href = 'https://wa.me/......';
}, 1000 );
}
// following is just a filler - don't mind it
function reportConversion(a) {
return;
}
<form className="orderForm">
<div className="form-group">
<div className="whatsapp" style="margin-top: 20px;">
<button
className="btn-primary"
onclick="reportConversionWrapper(event.target)"
type="button"
style="height:70px;width: 100%;"
>
<img
src="wat.png"
style="width: 36px;height: 36px; position: absolute; margin-left: -40px;margin-top: -10px;"
/>...text...
</button>
</div>
</div>
</form>

最新更新