Component({ properties: { active: { type: String, value: 'home', }, }, data: { navigating: false, }, methods: { safeReLaunch(url) { if (this.data.navigating) return; this.setData({ navigating: true }); wx.reLaunch({ url, complete: () => { // 路由完成后解锁;超时兜底避免卡死 setTimeout(() => { try { this.setData({ navigating: false }); } catch (_) { /* page may be gone */ } }, 300); }, }); }, onTap(e) { const key = e.currentTarget.dataset.key; if (!key || key === this.data.active || this.data.navigating) return; if (key === 'home') { this.safeReLaunch('/pages/home/home'); return; } if (key === 'notifications') { this.safeReLaunch('/pages/notifications/notifications'); return; } if (key === 'mine') { this.safeReLaunch('/pages/mine/mine'); return; } }, }, });