that.data取不到data中的值是为啥?
data: {
time:"",
count:1
},
checkup: function(){
//打卡
var TIME = util.formatTime(new Date());
this.data.time = TIME
//获取当前时间
var that = this
this.data.count = 1
var stic = getApp()
var getxuehao = stic.globalData.xuehao
//传递学号
console.log(this.data.count)
}
data: {
massage:"",
time:"",
count:1
},
getdata:function(e){
this.setData({
massage:e.detail.value
});
},
setmassage: function(){
//打卡
var TIME = util.formatTime(new Date());
this.data.time = TIME
//获取当前时间
var that = this
var stic = getApp()
var getxuehao = stic.globalData.xuehao
//传递学号
wx.cloud.init()
const db = wx.cloud.database()
//连接数据库
console.log(getxuehao)
console.log(that.data.count)
}
上下连段代码,下面那个可以直接打印出count值,上面那段打印结果为“Undefined” ,使用“this.data.count = 1”才能正确读值,两端代码一模一样,只是写在不同页面,实在理解不了是为啥,有没有大佬可以帮忙解释一下。