this.setData不能把数据存到上面的data里 求解求解!谢谢!
发布于 6 年前 作者 kxu 7702 次浏览 来自 问答

data: {

leavecord:[]

},

onLoad: function (options) {

wx.showLoading({

title: ‘加载中’,

})

var that = this

wx.getStorage({

key: ‘no’,

success: function(res) {

// console.log(res.data)

wx.request({

url: 'XXXXXXXX,  //路由没问题

method: ‘POST’,

header: {

‘content-type’: ‘application/x-www-form-urlencoded’

},

data: {

no:res.data

},

success(res) {

wx.hideLoading({

complete: true

});

console.log(res.data.leavecord)   //能在路由里取来数据

that.setData({

leavecord:res.data.leavecord    //这里不管用 存不到上面的data里

})

}

})

},

})

console.log(this.data.leavecord)  这里不显示东西

},

1 回复

怕不是你这么用的吧,data里面的数据又不是全局变量

回到顶部