-
Notifications
You must be signed in to change notification settings - Fork 493
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
fix(tabs): adjust the watch execution order of tabs and activeIndex #1936
base: main
Are you sure you want to change the base?
Conversation
activeKey={computedActiveKey.value} | ||
activeIndex={activeIndex.value} | ||
tabs={sortedTabs.value} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
仅修改 tabs 的顺序不能解决这个问题吧,这里不会影响 TabsNav 内部计算初始显示位置的时机
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原本是打算用 flush: 'sync'
或者immediate:true
来确保tabs的watch比activeIndex的watch先执行,在用vite写的demo的时候发现切换顺序也能让tabs的watch先执行。不过webpack中却不是这样的。保证watch的顺序还是得用flush: 'sync'
或者immediate:true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不过虽然可以让tabs的watch先执行,但是在activeIndex中的watch获取wrapperLength.value
和 maxOffset.value
不正确的值
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
activeIndex 中watch的nextTick
我直接换成了setTimeout
,也可以watch([tabs,activeIndex]
判断tabs
发生修改才用setTimeout
。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外就是直接设置activeIndex
为最后一项的时候,next
按钮并未置灰 。offset.value
值比maxOffset.value
小了几像素
a487fa6
to
94bf2c1
Compare
Types of changes
Background and context
Solution
How is the change tested?
Changelog
Checklist:
npm run test
)feature
branch and othersshould be submitted to
main
branch)Other information