我正在尝试开发一个加载消息的按钮.在html页面中我有
<div class="btn-area">
<button id="connectMetamaskBtn" class="btn sp-btn" type="button"
style="margin-top: 5%; width: 400px;"
loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> Connecting...">
Connect to Metamask
<img class="metamask-icon" src="assets/images/icons8-metamask-logo-48.png" width="25px" />
</button>
</div>
和app.js中
$("#connectMetamaskBtn").on("click", async () => {
var $this = $(this);
$this.button('loading');
try {
provider = new ethers.providers.Web3Provider(window.ethereum);
// MetaMask requires requesting permission to connect users accounts
await provider.send("eth_requestAccounts", []);
await startApp(provider);
}
catch (e) {
$this.button('reset');
$("#error")
.text(`An error occured: ${e.message || e}`)
.show();
}
});
加载不起作用...有什么想法吗?Thx
1条答案
按热度按时间nc1teljy1#
使用此按钮: