小程序如何将wx.request里的数据传出去

设置一个事件,用来测试
用类似于vue中的this.msg = result.data[1].receiver并不能把值传出去
但是用setData却可以,代码如下

 btnclick:function(){
    var that = this;
    wx.request({
      
      url: 'http://www.k1998.xyz/kjh/reciever.php',
      success: (result) => {
       console.log(result.data);
       //this.msg = result.data[1].receiver;
       //console.log(this.msg);
       that.setData({
        msg:result.data[1].receiver
      })
      }
    });
    
  }
发布了171 篇原创文章 · 获赞 29 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/weixin_43560272/article/details/104225502