微信小程序-显示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

猜你喜欢

转载自blog.csdn.net/z3287852/article/details/113420385