Bootstrap

小程序全局数据,tost弹窗

获取全局数据 

1.在app.js文件中设置

 globalData: {
    userInfo:{name:'王哈哈哈',age:99}
  }

2.准备一个新的页面用于获取全局数据

3.在新页面的js文件中获取实例,即可获取全局数据

// ----------------1.获取应用实例
const app = getApp();

Page({


  onLoad: function (options) {
    //------------------------- 2.输出全局数据
    console.log(app.globalData.userInfo);
  },

})

 小程序弹框

添加成功,提示信息

1.在wxml文件中写个按钮,用于触发方法

<!--pages/wxtoust/wxtoust.wxml-->

<button bindtap="tan1">showtoust</button>

 2.补充弹窗方法


// ----------------微信弹窗
tan1(){
  wx.showToast({
    title: '添加成功',
    icon:'error' //显示警告图标
    // icon:'loading' 显示加载图标
    // icon:'success' //显示一个勾
    // icon:'none' //不显示icon
  })
},

 更多弹窗

1.wxml文件

<!--pages/wxtoust/wxtoust.wxml-->
<text>pages/wxtoust/wxtoust.wxml</text>
<button bindtap="tan1">showtoust</button>

<button bindtap="tan2">loading弹框</button>  

<button bindtap="tan3">关闭loading弹框</button>  

<button bindtap="tan4">Model弹框,会弹出个确认,取消的确认弹窗</button>  

<button bindtap="tan5">Model弹框.下面会弹单选</button>  

<button bindtap="tan6">选择图片api,用手机会调出拍照,选图片</button>  

 2.js文件中的

// ----------------微信弹窗
tan1(){
  wx.showToast({
    title: '添加成功',
    icon:'error', //显示警告图标
    // icon:'loading' 显示加载图标
    // icon:'success' //显示一个勾
    // icon:'none' //不显示icon
    mask:true //防止操作穿透,有弹窗的时候点击任何地方都不好使
  })
},
tan1(){
  wx.showToast({
    title: '添加成功',
    icon:"error",
    mask:true
  })
},
tan2(){
  wx.showLoading({
    title: '正在上传',
  })
},
tan3(){
  wx.hideLoading()
},
tan4(){
  wx.showModal({
    title:"您确定要投诉吗?",
    content:"投诉要冲心悦3",
    cancelText:"充个P",
    cancelColor:"#333999",
    confirmText:"拿钱来",
    confirmColor:"#342789",
    success:(res)=>{
      if (res.confirm) {
        console.log("千媚了")
      } else {
        console.log("g没了")
      }
    }
  })

},
tan5(){
  wx.showActionSheet({
    itemList: ['A', 'B', 'C'],
    success (res) {
      console.log(res)
    },
    fail (res) {
      console.log(res.errMsg)
    }
  })
},
tan6(){
  wx.chooseImage({
    count: 8,
  })
},


悦读

道可道,非常道;名可名,非常名。 无名,天地之始,有名,万物之母。 故常无欲,以观其妙,常有欲,以观其徼。 此两者,同出而异名,同谓之玄,玄之又玄,众妙之门。

;