小程序调用另一个函数方法中的值

将A方法的值传递到B方法中:

inputPhoneNum:function(e){
	var anumber = e.detail.value   //anumber是随便起的名字
    this.setData({
      anumber: e.detail.value,     //通过setData方法将值存进去
    })
    // console.log(anumber)
}

在B方法中调用:

 getCode: function () {
  var cate = this.data.anumber     //cate就是A方法中anumber的值  通过this.data方法拿到A方法中的值
    app.http.codeMa({
      mobile: cate,                //mobile是接口返回数据参数
      event: "mobilelogin"         //evevt是接口返回的参数
    }).then(res => {
      console.log(res)
    })
 }

使用data中的值:

page({
data:{
    currentTime:30
}
inputNum:function(){
    var that = this;
    var currentTime = that.data.currentTime
}

})

小程序判断非空

Page({
  data: {
	phone: '',
    verification: '',
  }
  nextClick: function () {
    let phone = this.data.phone
    let verification = this.data.verification
     if (phone == "" || verification == "") {
      wx.showModal({
        title: '提示',
        content: '请输入完整信息!',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定')
          }
        }
      })
    }
  }  
})

你可能感兴趣的:(小程序)