html 带引导装置的加载按钮5

l3zydbqr  于 2023-01-15  发布在  其他
关注(0)|答案(1)|浏览(137)

我正在尝试开发一个加载消息的按钮.在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

nc1teljy

nc1teljy1#

使用此按钮:

$('.btn').on('click', function() {
    var $this = $(this);
  $this.button('loading');
    setTimeout(function() {
       $this.button('reset');
   }, 8000);
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css">

<div style="margin:3em;">
<button type="button" class="btn btn-primary btn-lg" id="load2" data-loading-text="<i class='fa fa-spinner fa-spin '></i> Processing Order">Submit Order</button>
</div>

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/bootstrap.min.js"></script>

相关问题