1. 程式人生 > 其它 >微信小程式-顯示loading的幾種方式:showToast 和 showLoading

微信小程式-顯示loading的幾種方式:showToast 和 showLoading

技術標籤:微信小程式

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

小程式wx.showToast()與wx.hideLoading()衝突的問題:https://www.cnblogs.com/-ting/p/12398310.html