onLoad(){
try {
var res = wx.getSystemInfoSync();
//每一个字母所占的高度
this.apHeight = res.windowHeight / 26;
//this.setData({ windowHeight: res.windowHeight });
this.windowHeight = res.windowHeight;
console.log(this.windowHeight );
} catch (e) {
}
}
打印结果
页面展示:
赋值成功了,但是页面没有更新过来
最终代码
onLoad(){
try {
var res = wx.getSystemInfoSync();
//每一个字母所占的高度
this.apHeight = res.windowHeight / 26;
//this.setData({ windowHeight: res.windowHeight });
this.windowHeight = res.windowHeight;
console.log(this.windowHeight);
this.$apply();
} catch (e) {
}
}
其实 this.$apply(),就是这句代码起作用了,。记录一下方便以后查阅