|
|
@@ -47,10 +47,23 @@
|
|
|
<script>
|
|
|
export default {
|
|
|
onShow() {
|
|
|
+ // 只允许跳转一次。onShow 在 devtools 重渲染、前后台切换时会重复触发,
|
|
|
+ // 多个 reLaunch 并发会让框架对已销毁的 webview 调用 routeDone,
|
|
|
+ // 报 "routeDone with a webviewId N is not found"。
|
|
|
+ if (this._hasLaunched) return
|
|
|
+ this._hasLaunched = true
|
|
|
// 显示 2 秒后自动跳转到首页
|
|
|
- setTimeout(() => {
|
|
|
+ this._launchTimer = setTimeout(() => {
|
|
|
+ this._launchTimer = null
|
|
|
uni.reLaunch({ url: '/pages/index-home/index' })
|
|
|
}, 2000)
|
|
|
+ },
|
|
|
+ onUnload() {
|
|
|
+ // 离开启动页时清掉尚未触发的定时器,避免对已销毁的页面再发起 reLaunch
|
|
|
+ if (this._launchTimer) {
|
|
|
+ clearTimeout(this._launchTimer)
|
|
|
+ this._launchTimer = null
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|