Skip to content
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(Picker): modelValue is optional #1071

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading