fix(tabbar): 修复直接进入非首页时tabbar索引不正确的问题

添加 setAutoCurIdx 方法根据当前路径自动设置正确的 tabbar 索引
This commit is contained in:
feige996
2025-08-13 20:15:08 +08:00
parent 9725b14626
commit 6f3d99402c
2 changed files with 15 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
import { navigateToInterceptor } from '@/router/interceptor'
import { tabbarStore } from './tabbar/store'
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
onLaunch((options) => {
@@ -13,6 +14,8 @@ onLaunch((options) => {
else {
navigateToInterceptor.invoke({ url: '/' })
}
// 处理直接进入路由非首页时tabbarIndex 不正确的问题
tabbarStore.setAutoCurIdx(options.path)
})
onShow((options) => {
console.log('App Show', options)