diff --git a/packages/vant/src/area/test/__snapshots__/index.spec.js.snap b/packages/vant/src/area/test/__snapshots__/index.spec.js.snap index 67059984e..4d0aac653 100644 --- a/packages/vant/src/area/test/__snapshots__/index.spec.js.snap +++ b/packages/vant/src/area/test/__snapshots__/index.spec.js.snap @@ -122,6 +122,14 @@ exports[`should render two columns when columns-num prop is two 1`] = ` +
+
+
+
`; diff --git a/packages/vant/src/picker/Picker.tsx b/packages/vant/src/picker/Picker.tsx index 049b1bd0c..8e3bb7c09 100644 --- a/packages/vant/src/picker/Picker.tsx +++ b/packages/vant/src/picker/Picker.tsx @@ -164,11 +164,12 @@ export default defineComponent({ formattedColumns.value = columns as PickerObjectColumn[]; } - hasOptions.value = formattedColumns.value.some( - (item) => - item[columnsFieldNames.value.values] && - item[columnsFieldNames.value.values].length !== 0 - ); + hasOptions.value = + formattedColumns.value.some( + (item) => + item[columnsFieldNames.value.values] && + item[columnsFieldNames.value.values].length !== 0 + ) || children.some((item) => item.hasOptions); }; // get indexes of all columns diff --git a/packages/vant/src/picker/PickerColumn.tsx b/packages/vant/src/picker/PickerColumn.tsx index 2768c8dd7..66f917526 100644 --- a/packages/vant/src/picker/PickerColumn.tsx +++ b/packages/vant/src/picker/PickerColumn.tsx @@ -283,6 +283,8 @@ export default defineComponent({ const getValue = (): PickerOption => state.options[state.index]; + const hasOptions = () => state.options.length; + setIndex(state.index); useParent(PICKER_KEY); @@ -292,6 +294,7 @@ export default defineComponent({ getValue, setValue, setOptions, + hasOptions, stopMomentum, });