var line1yend=33
Page({
data: {
line1yend:9,
requestData:[]
},
onShow: function () {
var THIS = this;
wx.request({
url: ‘http://127.0.0.1/util.js’,
data: {
x: ‘1’,
y: ‘2’
},
header: {
‘Content-Type’: ‘application/json’
},
success: function (res) {
var data = res.data;
THIS.setData({
requestData: data,
line1yend: res.data[0].电压
});
}
});
this.canvasClock()
} ,
canvasClock: function () {
var THIS = this;
console.log(THIS.data.line1yend)
}
})
如上代码,在 canvasClock中line1yend还是刚开始的值9 ,而不是从util.js里的值,可以正确从util.js取值,但line1yend不对