把success中的值赋值给局部变量
test:function(){
var session=null;
wx.request({
url: __PATH__ + ‘pages/login/login.php’,
header: {
“Content-Type”: “application/x-www-form-urlencoded;charset=utf-8”
},
method: ‘POST’,
data: { sessionkey: ‘asdsdsdsdsdsdsdsdsdsd’ },
success:function(res){
session=res.data;
console.log(session);
}
})
console.log(session);
}
我想把success中res.data赋值给外部变量session,可是运行结构是先打印出最后的session