WeChat Mini Program-Several ways to display loading: showToast and showLoading

1. Component form

<loading hidden="{
   
   {hidden}}">
    加载中...
</loading>

2. Dynamic form

showToast 和 showLoading

wx.showToast()

// Set the loading modal box

wx.showToast({title: '加载中', icon: 'loading', duration: 10000});
wx.hideToast();

// Use Cases

wx.showToast({title: '加载中', icon: 'loading', duration: 10000});
 
wx.request({
  url: ...,
  ...,
  success: (res) => {
  },
  fail: () => {},
  complete: () => {
    wx.hideToast()
  }
})

wx.showLoading()

wx.showLoading({title: ‘加载中…’})
wx.hideLoading()

// Use Cases

wx.showLoading({title: '加载中', icon: 'loading', duration: 10000});
 
wx.request({
  url: ...,
  ...,
  success: (res) => {
  },
  fail: () => {},
  complete: () => {
    wx.hideLoading()
  }
})

Reprinted from: https://blog.csdn.net/zww1984774346/article/details/84849159

 

The conflict between the small program wx.showToast() and wx.hideLoading(): https://www.cnblogs.com/-ting/p/12398310.html

 

Guess you like

Origin blog.csdn.net/z3287852/article/details/113420385