小程序开发-使用Loading和Toast提示框

小程序提示框

Loading提示框使用方式

1. 在wxml中作为组件使用
<loading hidden="{{hidden}}">
    加载中...
</loading>

通过设置hidden的值来控制Loading提示框的显示和隐藏

2. 在js中调用对应方法
  • 显示: wx.showLoading({title: "加载中…", duration: 2000})
  • 隐藏: wx.hideLoading()

Toast提示框的使用方式

mp-loading提示的使用

作为weui组件使用

  • app.json中配置
 "useExtendedLib": {
    "weui": true
  }
  • 在需要使用的页面json中导入
"usingComponents": {
        "mp-loading": "/miniprogram_npm/weui-miniprogram/loading/loading"
    },

详细可以参考: https://developers.weixin.qq.com/miniprogram/dev/extended/weui/loading.html

原文地址:https://www.cnblogs.com/limaostudio/p/13632994.html