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 = {
|
||||
text: string;
|
||||
value: string;
|
||||
children: string;
|
||||
text?: string;
|
||||
value?: string;
|
||||
children?: string;
|
||||
};
|
||||
|
||||
export default createComponent({
|
||||
|
@ -38,8 +38,6 @@ export type PickerOption =
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export type PickerStringColumn = string[];
|
||||
|
||||
export type PickerObjectColumn = {
|
||||
values?: PickerOption[];
|
||||
children?: PickerColumn;
|
||||
@ -49,7 +47,7 @@ export type PickerObjectColumn = {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export type PickerColumn = PickerStringColumn | PickerObjectColumn;
|
||||
export type PickerColumn = PickerOption[] | PickerObjectColumn;
|
||||
|
||||
function isOptionDisabled(option: PickerOption) {
|
||||
return isObject(option) && option.disabled;
|
||||
|
@ -83,7 +83,7 @@ export default createComponent({
|
||||
return 'object';
|
||||
}
|
||||
}
|
||||
return 'text';
|
||||
return 'plain';
|
||||
});
|
||||
|
||||
const formatCascade = () => {
|
||||
@ -121,7 +121,7 @@ export default createComponent({
|
||||
const format = () => {
|
||||
const { columns } = props;
|
||||
|
||||
if (dataType.value === 'text') {
|
||||
if (dataType.value === 'plain') {
|
||||
formattedColumns.value = [{ [valuesKey]: columns }];
|
||||
} else if (dataType.value === 'cascade') {
|
||||
formatCascade();
|
||||
@ -225,7 +225,7 @@ export default createComponent({
|
||||
};
|
||||
|
||||
const emitAction = (event: 'confirm' | 'cancel') => {
|
||||
if (dataType.value === 'text') {
|
||||
if (dataType.value === 'plain') {
|
||||
emit(event, getColumnValue(0), getColumnIndex(0));
|
||||
} else {
|
||||
emit(event, getValues(), getIndexes());
|
||||
@ -237,7 +237,7 @@ export default createComponent({
|
||||
onCascadeChange(columnIndex);
|
||||
}
|
||||
|
||||
if (dataType.value === 'text') {
|
||||
if (dataType.value === 'plain') {
|
||||
emit('change', getColumnValue(0), getColumnIndex(0));
|
||||
} else {
|
||||
emit('change', getValues(), columnIndex);
|
||||
|
Loading…
x
Reference in New Issue
Block a user