你定义了that = this,你应该log that.data.showDialog
setData修改了数据,页面为什么没有更新?// app.js initAppData() { return new Promise((resolve, reject) => { this.getVersion().then(res => { // 版本 console.log('版本:' + this.globalData.appletsVersion) if (res) this.getLocation().then(res => { // 经纬度 console.log('经纬度:' + this.globalData.location.latitude + ',' + this.globalData.location.longitude) if (res) this.getStoreList().then(res => { // 门店 console.log('门店:' + this.globalData.storeInfo.storeName) resolve(true) }) }) }) }) }, getLocation() { let that = this return new Promise((resolve, reject) => { wx.getLocation({ type: "wgs84", success(res) { var location = { latitude: res.latitude, longitude: res.longitude } that.globalData.location = location resolve(true) }, fail(err) { // 获取经纬度失败 reject(err) } }) }) }, //获取门店列表 getStoreList() { return new Promise((resolve, reject) => { resolve(true) // 涉及到接口调用,先直接resolve(true) }) }, // 获取小程序版本 getVersion() { return new Promise((resolve) => { resolve(true) // 涉及到接口调用,先直接resolve(true) }) }, // index.js const app = getApp() onShow() { app.initAppData().then(res => { this.setData({ // 修改 showDialog: true, }) console.log(this.data.showDialog) }) },
2022-07-25