错误:data is not defined;at "pages/Flower/flower" page lifeCycleMethod onLoad function
ReferenceError: data is not defined
页面的初始数据
*/
data: {
hasList: false, // 列表是否有数据
},
/**
生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.request({
url: 'http://localhost:3631/api/Flowers/Show',
method: 'GET',
data: {},
header: {
'content-type': 'application/json',
'Authorization': 'BasicAuth ' + data.data
},
success: function (res) {
console.log(res)
that.setData({
hasList: true,
carts: res.data
})
}
})
}
我之前写小程序,也遇到过这样的问题,不过我的是因为需要多加一个data。res.data.data然后就有数据了 ,百度只写了一个,至今我都还不明白为什么
https://segmentfault.com/q/1010000012690840/a-1020000012691357
你在that.setData({}),中的“that”有声明或者定义吗?