变量赋值后变成undefined
var jobNameList;
var apiUrl = getApp().globalData.apiUrl; //获取API接口地址
wx.request({
url: apiUrl + ‘api/User/GetJobNameList’,
method: ‘post’,
dataType: ‘json’,
header: {
‘content-type’: ‘application/json’
},
data: {
VerifyToken: verifyToken,
ComeFrom: getApp().globalData.comeFrom,
},
success: function(req) {
// console.log(req.data);
jobNameList = req.data;
},
error: function(req) {
}
})
console.log(jobNameList);
这里输入的时候为什么jobNameList变成了undefined ?