微信小程式-顯示loading的幾種方式:showToast 和 showLoading
阿新 • • 發佈:2021-02-19
技術標籤:微信小程式
1、元件形式
<loading hidden="{{hidden}}">
載入中...
</loading>
2、動態形式
showToast 和 showLoading
wx.showToast()
// 設定載入模態框
wx.showToast({title: '載入中', icon: 'loading', duration: 10000});
wx.hideToast();
// 使用案例
wx.showToast({title: '載入中', icon: 'loading', duration: 10000}); wx.request({ url: ..., ..., success: (res) => { }, fail: () => {}, complete: () => { wx.hideToast() } })
wx.showLoading()
wx.showLoading({title: ‘載入中…’})
wx.hideLoading()
// 使用案例
wx.showLoading({title: '載入中', icon: 'loading', duration: 10000});
wx.request({
url: ...,
...,
success: (res) => {
},
fail: () => {},
complete: () => {
wx.hideLoading()
}
})
轉自:https://blog.csdn.net/zww1984774346/article/details/84849159