在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/網(wǎng)絡安全  HTML/ 小程序組件的生命周期中如何調用methods定義的方法?

小程序組件的生命周期中如何調用methods定義的方法?

以下是小程序組件代碼

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

2017年1月19日 13:15