方法回调: 在index.js : find(){ app.findAllStudent2(function(res){ //传递一个函数过去 console.log(res); }) } 在app.js : findAllStudent2(method) { var vm = this; //进行请求网络 wx.request({ url: "http://127.0.0.1:8088/hello4", success(res) { console.log(res.data); method(res); //调用回调函数,这样就可以直接将res传递给find } }) }
//自己写一个方法A,在调用其它方法B时传递一个函数C过去,在那一个方法B中调用这个函数C,即可以在A中接受到消息!
注意wx.request是异步请求!!!
相关文章链接:https://www.cnblogs.com/moxiaowohuwei/p/8438236.html