Skip to content

Commit

Permalink
fix(Picker): modelValue is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Aug 31, 2023
1 parent d854a37 commit 8364779
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/picker/picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div v-for="(item, index) in realColumns" :key="index" :class="`${name}-item__group`">
<picker-item
:options="item"
:value="pickerValue[index]"
:value="pickerValue?.[index]"
:render-label="renderLabel"
@pick="handlePick($event, index)"
/>
Expand Down Expand Up @@ -57,15 +57,15 @@ export default defineComponent({
const confirmButtonText = computed(() => getDefaultText(props.confirmBtn, '确认'));
const cancelButtonText = computed(() => getDefaultText(props.cancelBtn, '取消'));
const header = computed(() => renderTNode(internalInstance, 'header'));
const curValueArray = ref(pickerValue.value.map((item: PickerValue) => item));
const curValueArray = ref(pickerValue.value?.map((item: PickerValue) => item) || []);
const realColumns = computed(() => {
if (typeof props.columns === 'function') {
return props.columns(curValueArray.value);
}
return props.columns;
});
const curIndexArray = realColumns.value.map((item: PickerColumn, index: number) => {
return getIndexFromColumns(item, pickerValue?.value[index]);
return getIndexFromColumns(item, pickerValue.value?.[index]);
});
const pickerItemInstanceArray = ref([]) as any;
Expand All @@ -91,7 +91,7 @@ export default defineComponent({
const { index } = context;
curIndexArray[column] = index;
curValueArray.value[column] = realColumns.value[column][index]?.value;
curValueArray.value[column] = realColumns.value?.[column][index]?.value;
props.onPick?.(curValueArray.value, { index, column });
};
Expand Down

0 comments on commit 8364779

Please sign in to comment.