mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(TreeSelect): some props can be string
This commit is contained in:
parent
5e658b08ce
commit
e2f1e6810b
@ -113,9 +113,9 @@ export default {
|
|||||||
|------|------|------|------|
|
|------|------|------|------|
|
||||||
| items | Required datasets for the component | *Item[]* | `[]` |
|
| items | Required datasets for the component | *Item[]* | `[]` |
|
||||||
| height | Height | *number \| string* | `300` |
|
| height | Height | *number \| string* | `300` |
|
||||||
| main-Active-index | The index of selected parent node | *number* | `0` |
|
| main-active-index | The index of selected parent node | *number \| string* | `0` |
|
||||||
| active-id | Id of selected item | *number \| string \| (number \| string)[]* | `0` |
|
| active-id | Id of selected item | *number \| string \|<br>(number \| string)[]* | `0` |
|
||||||
| max `v2.2.0` | Maximum number of selected items | *number* | `Infinity` |
|
| max `v2.2.0` | Maximum number of selected items | *number \| string* | `Infinity` |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@ -121,9 +121,9 @@ export default {
|
|||||||
|------|------|------|------|
|
|------|------|------|------|
|
||||||
| items | 分类显示所需的数据 | *Item[]* | `[]` |
|
| items | 分类显示所需的数据 | *Item[]* | `[]` |
|
||||||
| height | 高度,默认单位为`px` | *number \| string* | `300` |
|
| height | 高度,默认单位为`px` | *number \| string* | `300` |
|
||||||
| main-active-index | 左侧选中项的索引 | *number* | `0` |
|
| main-active-index | 左侧选中项的索引 | *number \| string* | `0` |
|
||||||
| active-id | 右侧选中项的 id,支持传入数组 | *number \| string \| (number \| string)[]* | `0` |
|
| active-id | 右侧选中项的 id,支持传入数组 | *number \| string \|<br>(number \| string)[]* | `0` |
|
||||||
| max `v2.2.0` | 右侧项最大选中个数 | *number* | `Infinity` |
|
| max `v2.2.0` | 右侧项最大选中个数 | *number \| string* | `Infinity` |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ export type TreeSelectChildren = {
|
|||||||
export type TreeSelectActiveId = number | string | (number | string)[];
|
export type TreeSelectActiveId = number | string | (number | string)[];
|
||||||
|
|
||||||
export type TreeSelectProps = {
|
export type TreeSelectProps = {
|
||||||
max: number;
|
max: number | string;
|
||||||
height: number | string;
|
height: number | string;
|
||||||
items: TreeSelectItem[];
|
items: TreeSelectItem[];
|
||||||
activeId: TreeSelectActiveId;
|
activeId: TreeSelectActiveId;
|
||||||
mainActiveIndex: number;
|
mainActiveIndex: number | string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TreeSelectSlots = DefaultSlots & {
|
export type TreeSelectSlots = DefaultSlots & {
|
||||||
@ -50,7 +50,7 @@ function TreeSelect(
|
|||||||
) {
|
) {
|
||||||
const { height, items, mainActiveIndex, activeId } = props;
|
const { height, items, mainActiveIndex, activeId } = props;
|
||||||
|
|
||||||
const selectedItem: Partial<TreeSelectItem> = items[mainActiveIndex] || {};
|
const selectedItem: Partial<TreeSelectItem> = items[+mainActiveIndex] || {};
|
||||||
const subItems = selectedItem.children || [];
|
const subItems = selectedItem.children || [];
|
||||||
const isMultiple = Array.isArray(activeId);
|
const isMultiple = Array.isArray(activeId);
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ function TreeSelect(
|
|||||||
|
|
||||||
TreeSelect.props = {
|
TreeSelect.props = {
|
||||||
max: {
|
max: {
|
||||||
type: Number,
|
type: [Number, String],
|
||||||
default: Infinity,
|
default: Infinity,
|
||||||
},
|
},
|
||||||
items: {
|
items: {
|
||||||
@ -152,7 +152,7 @@ TreeSelect.props = {
|
|||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
mainActiveIndex: {
|
mainActiveIndex: {
|
||||||
type: Number,
|
type: [Number, String],
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user