loading加载中效果两种实现方法_微信小程序教程-大众资源网
方法一
直接在代码里掌控,在wxml文件里布局弹窗loading层,利用条件图形,在JS代码里控制与否表明loading层。
文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-react.html?t=20161107#wxshowtoastobject
js代码
showLoading:function(){ wx.showToast({ title: '加载中', icon: 'loading' }); },cancelLoading:function(){ wx.hideToast(); }
方法二
在wxml文件里布局弹窗,利用条件渲染,在js代码里掌控与否表明
文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/framework/view/wxml/list.html?t=20161107
wxml代码
<view > <loading wx:if="{{showLoading}}">加载中</loading> </view>
js
data: { showLoading:true},showLoading:function(){ this.setData({ showLoading:true }) },cancelLoading:function(){ this.setData({ showLoading:false})