From 4b2e175130cfa307a42cc905d31d397a759f8953 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 20 Feb 2020 21:50:29 +0800 Subject: [PATCH] fix(v3): switchTab(entryPagePath) --- packages/uni-app-plus/dist/index.v3.js | 10 ++++++---- src/platforms/app-plus/service/framework/app.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/uni-app-plus/dist/index.v3.js b/packages/uni-app-plus/dist/index.v3.js index de772e23d..527f20727 100644 --- a/packages/uni-app-plus/dist/index.v3.js +++ b/packages/uni-app-plus/dist/index.v3.js @@ -12297,10 +12297,6 @@ var serviceContext = (function () { __uniConfig.tabBar.selected = 0; const selected = __uniConfig.tabBar.list.findIndex(page => page.pagePath === __uniConfig.entryPagePath); - if (selected !== -1) { - // 取当前 tab 索引值 - __uniConfig.tabBar.selected = selected; - } tabBar$1.init(__uniConfig.tabBar, (item, index) => { uni.switchTab({ @@ -12316,6 +12312,12 @@ var serviceContext = (function () { } }); }); + + if (selected !== -1) { + // 取当前 tab 索引值 + __uniConfig.tabBar.selected = selected; + selected !== 0 && tabBar$1.switchTab(__uniConfig.entryPagePath); + } } function initEntryPage () { diff --git a/src/platforms/app-plus/service/framework/app.js b/src/platforms/app-plus/service/framework/app.js index 103be320f..2e2881d4d 100644 --- a/src/platforms/app-plus/service/framework/app.js +++ b/src/platforms/app-plus/service/framework/app.js @@ -119,10 +119,6 @@ function initTabBar () { __uniConfig.tabBar.selected = 0 const selected = __uniConfig.tabBar.list.findIndex(page => page.pagePath === __uniConfig.entryPagePath) - if (selected !== -1) { - // 取当前 tab 索引值 - __uniConfig.tabBar.selected = selected - } tabBar.init(__uniConfig.tabBar, (item, index) => { uni.switchTab({ @@ -138,6 +134,12 @@ function initTabBar () { } }) }) + + if (selected !== -1) { + // 取当前 tab 索引值 + __uniConfig.tabBar.selected = selected + selected !== 0 && tabBar.switchTab(__uniConfig.entryPagePath) + } } function initEntryPage () { -- GitLab