success返回值怎么给外部变量赋值

发布于 6 年前作者 lingang19009 次浏览最后编辑 6 年前来自 ask

function Info(uid) {

var that = this;

var head;

wx.request({

url: ‘’,

data: {

},

header: {

‘content-type’: ‘application/json’

},

success(res) {

that.head = res.data.head;

console.log(that.head);

}

})

console.log(that.head)

return that.head;

}

module.exports.Info = Info;

3 回复
gang10
gang101 楼6 年前

不要that. 就对了。。

tanqiang
tanqiang2 楼6 年前

楼上正确,另外,需要看几篇关于【js 作用域 this】的文章

wei57
wei573 楼4 年前

外部的head和success里的head不是同一个,我要怎么给外部的head赋值