咱們在學習微信小程序時,應該會遇到載入圖片或者動畫須要等待的狀況,那麼這個等待的畫面咱們應該怎麼編寫呢?今天咱們就寫一個這樣的小教程。
先來看效果圖:
html
重要代碼
1.首頁代碼:html5
<view class="copyright"> <view class="copyright_item">CopyRight:All Right Reserved</view> <view class="copyright_item">原創做者:HTML51.COM</view> <view class="copyright_item">微信小程序開發者社區:51小程序</view> <view class="copyright_item"><image class="img" src="../copyright/image/logo.png"/></view> <view class="goto_counter"><button type="default" bindtap="goto_counter">點擊進入彈出loading加載框頁面</button></view> </view>
2..js代碼小程序
Page({ data: { loadingHidden: true }, loadingTap: function(){ this.setData({ loadingHidden: false }); var that = this; setTimeout(function(){ that.setData({ loadingHidden: true }); that.update(); }, 3000); } })
loading頁面代碼微信小程序
<loading hidden="{{loadingHidden}}"> 加載中... </loading> <button type="default" bindtap="loadingTap">點擊彈出loading</button>
源碼下載地址:http://bbs.html51.com/t-1087-...微信