【微信小程序学习笔记】弹窗的两种姿势
2016-11-09 本文已影响0人
弓长剑鸣
-
直接在代码里控制
-
文档地址:
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 })
-