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

  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

      
         加载中
      
      
    • js

      data: {
            showLoading:true
      },
      showLoading:function(){
           this.setData({
              showLoading:true
           })
        },
      cancelLoading:function(){
          this.setData({
              showLoading:false
      })
      

你可能感兴趣的:(【微信小程序学习笔记】弹窗的两种姿势)