mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 15:09:16 +08:00
types(Cascader): fieldNames should be optional (#8139)
This commit is contained in:
commit
54be2b3c0a
@ -22,9 +22,9 @@ type CascaderTab = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type CascaderFieldNames = {
|
type CascaderFieldNames = {
|
||||||
text: string;
|
text?: string;
|
||||||
value: string;
|
value?: string;
|
||||||
children: string;
|
children?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
|
@ -38,8 +38,6 @@ export type PickerOption =
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PickerStringColumn = string[];
|
|
||||||
|
|
||||||
export type PickerObjectColumn = {
|
export type PickerObjectColumn = {
|
||||||
values?: PickerOption[];
|
values?: PickerOption[];
|
||||||
children?: PickerColumn;
|
children?: PickerColumn;
|
||||||
@ -49,7 +47,7 @@ export type PickerObjectColumn = {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PickerColumn = PickerStringColumn | PickerObjectColumn;
|
export type PickerColumn = PickerOption[] | PickerObjectColumn;
|
||||||
|
|
||||||
function isOptionDisabled(option: PickerOption) {
|
function isOptionDisabled(option: PickerOption) {
|
||||||
return isObject(option) && option.disabled;
|
return isObject(option) && option.disabled;
|
||||||
|
@ -83,7 +83,7 @@ export default createComponent({
|
|||||||
return 'object';
|
return 'object';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 'text';
|
return 'plain';
|
||||||
});
|
});
|
||||||
|
|
||||||
const formatCascade = () => {
|
const formatCascade = () => {
|
||||||
@ -121,7 +121,7 @@ export default createComponent({
|
|||||||
const format = () => {
|
const format = () => {
|
||||||
const { columns } = props;
|
const { columns } = props;
|
||||||
|
|
||||||
if (dataType.value === 'text') {
|
if (dataType.value === 'plain') {
|
||||||
formattedColumns.value = [{ [valuesKey]: columns }];
|
formattedColumns.value = [{ [valuesKey]: columns }];
|
||||||
} else if (dataType.value === 'cascade') {
|
} else if (dataType.value === 'cascade') {
|
||||||
formatCascade();
|
formatCascade();
|
||||||
@ -225,7 +225,7 @@ export default createComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const emitAction = (event: 'confirm' | 'cancel') => {
|
const emitAction = (event: 'confirm' | 'cancel') => {
|
||||||
if (dataType.value === 'text') {
|
if (dataType.value === 'plain') {
|
||||||
emit(event, getColumnValue(0), getColumnIndex(0));
|
emit(event, getColumnValue(0), getColumnIndex(0));
|
||||||
} else {
|
} else {
|
||||||
emit(event, getValues(), getIndexes());
|
emit(event, getValues(), getIndexes());
|
||||||
@ -237,7 +237,7 @@ export default createComponent({
|
|||||||
onCascadeChange(columnIndex);
|
onCascadeChange(columnIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataType.value === 'text') {
|
if (dataType.value === 'plain') {
|
||||||
emit('change', getColumnValue(0), getColumnIndex(0));
|
emit('change', getColumnValue(0), getColumnIndex(0));
|
||||||
} else {
|
} else {
|
||||||
emit('change', getValues(), columnIndex);
|
emit('change', getValues(), columnIndex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user