微信小程序-显示loading的几种方式

1、组件形式


2、动态形式

showToast 和 showLoading

wx.showToast() wx.showLoading()
参数 itle icon image duration mask title mask
关闭方法 设置duration,定时关闭;使用wx.hideToast()关闭 只能用wx.hideLoading()关闭
icon success loading none 固定显示加载icon

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()
  }
})

你可能感兴趣的:(微信小程序基础,微信小程序笔记)