fix(select): After directly modifying the v-model value and updating the options list, the view displayed incorrectly. #3213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Types of changes
Background and context
EN:
I need to implement selection followed by pagination using a select component, which includes a "Select All" function (accomplished by directly adding values to the
v-model
). However, this approach of setting values encounters issues when the:options
are updated afterwards, leading to inconsistencies in the displayed selection.CN:
我需要使用选择(Select)组件实现选中项目后进行分页的功能,并且这个组件需要包含全选的功能(通过直接给
v-model
增加值的方式来实现全选)。但是,采用这种方式设置值后,一旦选项(:options
)数据发生更新,就会出现显示不一致的问题,即已选择的项目状态与实际不符。Bug reproduction
Solution
EN:
Avoided redundant calls to
updateSelectedOption
when modelValue changes, ensuring efficient updates only when necessary.CN:
在modelValue发生改变时,优化措施有效避免了
updateSelectedOption
方法的重复调用,仅在确实需要更新时才会触发,从而确保了更新过程的高效性。How is the change tested?
Changelog
Checklist:
npm run test
)feature
branch and othersshould be submitted to
main
branch)Other information