設置button的loading屬性,同時使用定時器


點擊按鈕,出現loading狀態,兩秒后取消loading:

1 <!-- 設置button的loading屬性 -->
2 <button loading="{{loading}}" bindtap="tap">操作</button>
 1 Page({
 2 
 3   data: {
 4     loading: false
 5   },
 6 
 7   tap: function() {
 8 
 9     // 把按鈕的loading狀態顯示出來
10     this.setData({
11       loading: true
12     });
13 
14     var _this = this;
15     // 接着做耗時的操作...
16 
17     //設置兩秒后取消loading狀態
18     setTimeout(function() {
19       // console.log("延遲調用============");
20       _this.setData({
21         loading: false
22       });
23     }, 2000);
24   }
25 })

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM