【微信小程序学习笔记】弹窗的两种姿势

来源:互联网 发布:oracle sql教程 编辑:程序博客网 时间:2024/05/14 13:36
  1. 直接在代码里控制

    • 文档地址:
      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();  }

  2. 在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})

ITDogFire –弓长剑鸣

0 0
原创粉丝点击