【微信小程序】TypeError: Cannot read property 'setData' of undefined

解决方案 https://www.jianshu.com/p/4f7b33e3e1df

 

对比分析

success: (res) => {
        console.log("(res) => { }时:" + this);
      },

--------------

success: function (res){
        console.log("function (res)时:" + this);
       },

 输出台结果

function (res)时:undefined
 (res) => { }时:[object Object]

 1、如果函数作为对象的方法调用,this指向的是这个上级对象,即调用方法的对象
2、如果是构造函数中的this,则this指向新创建的对象本身

问题是解决了但是 还是不太懂。。。学习js基础先~~~

发布了484 篇原创文章 · 获赞 235 · 访问量 37万+

猜你喜欢

转载自blog.csdn.net/shiliang97/article/details/104778358
今日推荐