feat(TreeSelect): some props can be string

This commit is contained in:
陈嘉涵 2020-01-31 10:20:36 +08:00
parent 5e658b08ce
commit e2f1e6810b
3 changed files with 11 additions and 11 deletions

View File

@ -113,9 +113,9 @@ export default {
|------|------|------|------|
| items | Required datasets for the component | *Item[]* | `[]` |
| height | Height | *number \| string* | `300` |
| main-Active-index | The index of selected parent node | *number* | `0` |
| active-id | Id of selected item | *number \| string \| (number \| string)[]* | `0` |
| max `v2.2.0` | Maximum number of selected items | *number* | `Infinity` |
| main-active-index | The index of selected parent node | *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 \| string* | `Infinity` |
### Events

View File

@ -121,9 +121,9 @@ export default {
|------|------|------|------|
| items | 分类显示所需的数据 | *Item[]* | `[]` |
| height | 高度,默认单位为`px` | *number \| string* | `300` |
| main-active-index | 左侧选中项的索引 | *number* | `0` |
| active-id | 右侧选中项的 id支持传入数组 | *number \| string \| (number \| string)[]* | `0` |
| max `v2.2.0` | 右侧项最大选中个数 | *number* | `Infinity` |
| main-active-index | 左侧选中项的索引 | *number \| string* | `0` |
| active-id | 右侧选中项的 id支持传入数组 | *number \| string \|<br>(number \| string)[]* | `0` |
| max `v2.2.0` | 右侧项最大选中个数 | *number \| string* | `Infinity` |
### Events

View File

@ -29,11 +29,11 @@ export type TreeSelectChildren = {
export type TreeSelectActiveId = number | string | (number | string)[];
export type TreeSelectProps = {
max: number;
max: number | string;
height: number | string;
items: TreeSelectItem[];
activeId: TreeSelectActiveId;
mainActiveIndex: number;
mainActiveIndex: number | string;
};
export type TreeSelectSlots = DefaultSlots & {
@ -50,7 +50,7 @@ function TreeSelect(
) {
const { height, items, mainActiveIndex, activeId } = props;
const selectedItem: Partial<TreeSelectItem> = items[mainActiveIndex] || {};
const selectedItem: Partial<TreeSelectItem> = items[+mainActiveIndex] || {};
const subItems = selectedItem.children || [];
const isMultiple = Array.isArray(activeId);
@ -136,7 +136,7 @@ function TreeSelect(
TreeSelect.props = {
max: {
type: Number,
type: [Number, String],
default: Infinity,
},
items: {
@ -152,7 +152,7 @@ TreeSelect.props = {
default: 0,
},
mainActiveIndex: {
type: Number,
type: [Number, String],
default: 0,
},
};