Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tabbar版本 重新进来,不会停留在上一次的页面上,但是底下的tabbar会在上一次的地方高亮。 #150

Open
xmvigour opened this issue Jul 25, 2024 · 1 comment

Comments

@xmvigour
Copy link

/src/components/fg-tabbar/fg-tabbar.vue

建议在这里优化下代码
原代码:
function selectTabBar({ value: index }: { value: number }) { // const url = tabbarList[index].path // tabbarStore.setCurIdx(index) // uni.switchTab({ url }) doSelTabBar(index) } const doSelTabBar = (index: number) => { const url = tabbarList[index].path tabbarStore.setCurIdx(index) uni.switchTab({ url }) } onLoad(() => { // 解决原生 tabBar 未隐藏导致有2个 tabBar 的问题 // #ifdef APP-PLUS | H5 uni.hideTabBar({ fail(err) { console.log('hideTabBar fail: ', err) }, success(res) { console.log('hideTabBar success: ', res) }, }) // #endif // add by xmvigour 重新进入的时候进入上一次的tab if (tabbarStore.curIdx > 0) { // selectTabBar(tabbarStore.curIdx) doSelTabBar(tabbarStore.curIdx) console.log('tabbarStore.curIdx', tabbarStore.curIdx) } })

改完以后:(onload坐一下判断 )
function selectTabBar({ value: index }: { value: number }) { // const url = tabbarList[index].path // tabbarStore.setCurIdx(index) // uni.switchTab({ url }) doSelTabBar(index) } const doSelTabBar = (index: number) => { const url = tabbarList[index].path tabbarStore.setCurIdx(index) uni.switchTab({ url }) } onLoad(() => { // 解决原生 tabBar 未隐藏导致有2个 tabBar 的问题 // #ifdef APP-PLUS | H5 uni.hideTabBar({ fail(err) { console.log('hideTabBar fail: ', err) }, success(res) { console.log('hideTabBar success: ', res) }, }) // #endif // add by xmvigour 重新进入的时候进入上一次的tab if (tabbarStore.curIdx > 0) { // selectTabBar(tabbarStore.curIdx) doSelTabBar(tabbarStore.curIdx) console.log('tabbarStore.curIdx', tabbarStore.curIdx) } })

@feige996
Copy link
Contributor

feige996 commented Sep 6, 2024

兄弟,提个PR 吧,新仓库用 codercup2/unibest, 在新仓库里面提。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants