diff --git a/miniprogram/pages/closet-share/closet-share.ts b/miniprogram/pages/closet-share/closet-share.ts index 477ae1c..005ff46 100644 --- a/miniprogram/pages/closet-share/closet-share.ts +++ b/miniprogram/pages/closet-share/closet-share.ts @@ -31,6 +31,13 @@ Page({ redirectToLogin() return } + // 首帧渲染未结束就 setData 会触发「Expected updated data but get first rendering data」, + // 整个 webview 渲染失败。首次 onShow 的刷新延迟到下一帧 + if (!(this as any).firstShown) { + ;(this as any).firstShown = true + wx.nextTick(() => this.refresh()) + return + } this.refresh() }, diff --git a/miniprogram/pages/horoscope/horoscope.ts b/miniprogram/pages/horoscope/horoscope.ts index acdc39a..089d15a 100644 --- a/miniprogram/pages/horoscope/horoscope.ts +++ b/miniprogram/pages/horoscope/horoscope.ts @@ -45,10 +45,17 @@ Page({ redirectToLogin() return } - // 跨天回到本页时旧数据仍是昨天的,需重新拉取 + // 首帧渲染未结束就 setData 会触发「Expected updated data but get first rendering data」, + // 整个 webview 渲染失败,用户视觉上仍看到上一个页面。首次 onShow 的数据拉取延迟到下一帧 const stale = !this.data.horoscope || Number(this.data.horoscope.stat_date) !== todayStatDate() - if (stale) this.fetchHoroscope(0) + if (!stale) return + if (!(this as any).firstShown) { + ;(this as any).firstShown = true + wx.nextTick(() => this.fetchHoroscope(0)) + return + } + this.fetchHoroscope(0) }, syncTabBar() { diff --git a/miniprogram/pages/outfit/outfit.ts b/miniprogram/pages/outfit/outfit.ts index 22a09fe..c0beefa 100644 --- a/miniprogram/pages/outfit/outfit.ts +++ b/miniprogram/pages/outfit/outfit.ts @@ -36,6 +36,13 @@ Page({ this.setData({ activeTab: 1, list: [], loading: true }) } } + // 首帧渲染未结束就 setData 会触发「Expected updated data but get first rendering data」, + // 整个 webview 渲染失败,用户视觉上仍看到上一个页面。首次 onShow 的刷新延迟到下一帧 + if (!(this as any).firstShown) { + ;(this as any).firstShown = true + wx.nextTick(() => this.refresh()) + return + } this.refresh() }, diff --git a/miniprogram/pages/wardrobe/wardrobe.ts b/miniprogram/pages/wardrobe/wardrobe.ts index 65eeddd..dcf73b7 100644 --- a/miniprogram/pages/wardrobe/wardrobe.ts +++ b/miniprogram/pages/wardrobe/wardrobe.ts @@ -41,6 +41,15 @@ Page({ redirectToLogin() return } + // 首帧渲染未结束就 setData 会触发「Expected updated data but get first rendering data」, + // 整个 webview 渲染失败,用户视觉上仍看到上一个页面(从 login switchTab 过来时表现为 + // "卡在登录页")。把首次 onShow 的刷新延迟到下一帧,规避首帧冲突。 + if (!(this as any).firstShown) { + ;(this as any).firstShown = true + wx.nextTick(() => this.refresh()) + return + } + logger.debug(LOG, 'onShow 触发刷新') this.refresh() },