VUE - 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法

 created() {
    var that=this
    axios.get('http://jsonplaceholder.typicode.com/todos')
    .then(function (res) {
      // handle success
      // console.log(res);
      that.todos = res.data
    })
    .catch(function (error) {
      // handle error
      console.log(error);
    })
    .finally(function () {
      // always executed
    });
    },
}

 

posted @ 2019-11-02 13:09  武卡卡  阅读(620)  评论(0编辑  收藏  举报