1.由于小程序wx.request()方法是异步的,在app.js执行ajax后,各分页加载app.js的全局数据时,无法按顺序加载。例:
//app.js App({ ajax:function(){ let that = this; wx.request({ url: \'https://a.com/url.php\', method: \'GET\', success: function(e){ that.data = 123; } }) }; }) //content.js let app = getApp() Page({ getData: function(){ app.ajax(); console.log(app.data); //undefined } })