Skip to content

Commit 8530440

Browse files
fix: 🐛 修复picker-view动态设置columns时获取选中值异常的问题 (#518)
Closes: #492
1 parent 3cd0905 commit 8530440

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/uni_modules/wot-design-uni/components/wd-picker-view/wd-picker-view.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ const selectedIndex = ref<Array<number>>([]) // 格式化之后,每列选中
5757
watch(
5858
[() => props.modelValue, () => props.columns],
5959
(newValue, oldValue) => {
60-
if (!isEqual(oldValue[1], newValue[1])) {
60+
if (!isEqual(oldValue[1], newValue[1]) && isArray(newValue[1]) && newValue[1].length > 0) {
6161
formatColumns.value = formatArray(newValue[1], props.valueKey, props.labelKey)
6262
}
63-
if (!isEqual(oldValue[0], newValue[0]) && isDef(newValue[0])) {
63+
if (isDef(newValue[0])) {
6464
selectWithValue(newValue[0])
6565
}
6666
},
@@ -79,7 +79,6 @@ const { proxy } = getCurrentInstance() as any
7979
*/
8080
function selectWithValue(value: string | number | boolean | number[] | string[] | boolean[]) {
8181
if (formatColumns.value.length === 0) return
82-
8382
// 使其默认选中首项
8483
if (value === '' || !isDef(value) || (isArray(value) && value.length === 0)) {
8584
value = formatColumns.value.map((col) => {

0 commit comments

Comments
 (0)