以下是小程序组件代码
methods: {
getList: function () {
util.get(`${config.service.host}/web/news/list_with_pub_info?channelId=${config.channelId}&page=${that.data.page}&size=${that.data.size}`, function (res) {
that.setData({
newsList: res.data.content,
totalPages: res.data.totalPages
})
}, function (e) {
console.log(JSON.stringify(e));
});
},
},
ready: function (options) {
let that = this;
this.getList();//这里调用方法会报错undefined,请问该如何调用呢?
},
首先,这个在onLoad里面调用,然后你都
let that = this
然后在this.getList
肯定是undefined啊,你要不就不要let that = this
,要不就that.getList
,上面的getList里面也有错误,getList方法里面加上let that = this