From 8d2c4b1e4671e7e154c16da4228cbb618e195963 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 29 Sep 2020 20:49:22 +0800 Subject: [PATCH] feat(CollapseItem): add toggle method (#7281) * feat(CollapseItem): add toggle method * chore: update doc --- src/address-edit/README.md | 2 +- src/address-edit/README.zh-CN.md | 2 +- src/area/README.md | 2 +- src/area/README.zh-CN.md | 2 +- src/calendar/README.md | 2 +- src/calendar/README.zh-CN.md | 2 +- src/checkbox/README.md | 4 +- src/checkbox/README.zh-CN.md | 4 +- src/collapse-item/index.js | 10 +++-- src/collapse/README.md | 8 ++++ src/collapse/README.zh-CN.md | 22 +++++++---- src/collapse/test/index.spec.js | 58 +++++++++++++++++++++++++++++ src/count-down/README.md | 2 +- src/count-down/README.zh-CN.md | 2 +- src/datetime-picker/README.md | 2 +- src/datetime-picker/README.zh-CN.md | 2 +- src/dropdown-menu/README.md | 8 ++-- src/dropdown-menu/README.zh-CN.md | 4 +- src/field/README.md | 2 +- src/field/README.zh-CN.md | 2 +- src/form/README.md | 2 +- src/form/README.zh-CN.md | 2 +- src/list/README.md | 2 +- src/list/README.zh-CN.md | 2 +- src/picker/README.md | 2 +- src/picker/README.zh-CN.md | 2 +- src/sku/README.md | 2 +- src/sku/README.zh-CN.md | 2 +- src/swipe-cell/README.md | 2 +- src/swipe-cell/README.zh-CN.md | 2 +- src/swipe/README.md | 2 +- src/swipe/README.zh-CN.md | 2 +- src/tab/README.md | 2 +- src/tab/README.zh-CN.md | 2 +- src/uploader/README.md | 2 +- src/uploader/README.zh-CN.md | 2 +- types/collapse-item.d.ts | 5 +++ types/index.d.ts | 3 +- 38 files changed, 132 insertions(+), 50 deletions(-) create mode 100644 types/collapse-item.d.ts diff --git a/src/address-edit/README.md b/src/address-edit/README.md index 8b4d54a18..c1256d35e 100644 --- a/src/address-edit/README.md +++ b/src/address-edit/README.md @@ -112,7 +112,7 @@ export default { ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get AddressEdit instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get AddressEdit instance and call instance methods. | Name | Description | Attribute | Return value | | ---------------- | ------------------ | --------------------- | ------------ | diff --git a/src/address-edit/README.zh-CN.md b/src/address-edit/README.zh-CN.md index 6e0af8dd4..23e331f4a 100644 --- a/src/address-edit/README.zh-CN.md +++ b/src/address-edit/README.zh-CN.md @@ -112,7 +112,7 @@ export default { ### 方法 -通过 ref 可以获取到 AddressEdit 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 AddressEdit 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | ---------------- | ------------ | --------------------- | ------ | diff --git a/src/area/README.md b/src/area/README.md index df47e9d37..2a063927f 100644 --- a/src/area/README.md +++ b/src/area/README.md @@ -89,7 +89,7 @@ To have a selected value,simply pass the `code` of target area to `value` prop ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Area instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get Area instance and call instance methods. | Name | Description | Attribute | Return value | | ----- | ------------------------- | ------------- | ------------ | diff --git a/src/area/README.zh-CN.md b/src/area/README.zh-CN.md index 60321d4b6..9ab47d544 100644 --- a/src/area/README.zh-CN.md +++ b/src/area/README.zh-CN.md @@ -89,7 +89,7 @@ Vue.use(Area); ### 方法 -通过 ref 可以获取到 Area 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 Area 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/src/calendar/README.md b/src/calendar/README.md index 259b3b768..70c9db79b 100644 --- a/src/calendar/README.md +++ b/src/calendar/README.md @@ -312,7 +312,7 @@ Following props are supported when the type is multiple ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Calendar instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get Calendar instance and call instance methods. | Name | Description | Attribute | Return value | | ----- | ----------------------------------- | --------- | ------------ | diff --git a/src/calendar/README.zh-CN.md b/src/calendar/README.zh-CN.md index 20d8c0b17..a7c8fb1a4 100644 --- a/src/calendar/README.zh-CN.md +++ b/src/calendar/README.zh-CN.md @@ -316,7 +316,7 @@ export default { ### 方法 -通过 ref 可以获取到 Calendar 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 Calendar 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | ------ | ---------------------- | ---- | ------ | diff --git a/src/checkbox/README.md b/src/checkbox/README.md index 2b358a215..3f6321f27 100644 --- a/src/checkbox/README.md +++ b/src/checkbox/README.md @@ -255,7 +255,7 @@ export default { ### CheckboxGroup Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get CheckboxGroup instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get CheckboxGroup instance and call instance methods. | Name | Description | Attribute | Return value | | --- | --- | --- | --- | @@ -263,7 +263,7 @@ Use [ref](https://vuejs.org/v2/api/#ref) to get CheckboxGroup instance and call ### Checkbox Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Checkbox instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get Checkbox instance and call instance methods. | Name | Description | Attribute | Return value | | ------ | ------------------- | ------------------- | ------------ | diff --git a/src/checkbox/README.zh-CN.md b/src/checkbox/README.zh-CN.md index 539ef31d2..20b84d1e1 100644 --- a/src/checkbox/README.zh-CN.md +++ b/src/checkbox/README.zh-CN.md @@ -275,7 +275,7 @@ export default { ### CheckboxGroup 方法 -通过 ref 可以获取到 CheckboxGroup 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 CheckboxGroup 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | @@ -283,7 +283,7 @@ export default { ### Checkbox 方法 -通过 ref 可以获取到 Checkbox 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 Checkbox 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/src/collapse-item/index.js b/src/collapse-item/index.js index f84910079..d74fac88e 100644 --- a/src/collapse-item/index.js +++ b/src/collapse-item/index.js @@ -105,15 +105,17 @@ export default createComponent({ methods: { onClick() { - if (this.disabled) { - return; + if (!this.disabled) { + this.toggle(); } + }, + // @exposed-api + toggle(expanded = !this.expanded) { const { parent, currentName } = this; const close = parent.accordion && currentName === parent.value; const name = close ? '' : currentName; - - parent.switch(name, !this.expanded); + this.parent.switch(name, expanded); }, onTransitionEnd() { diff --git a/src/collapse/README.md b/src/collapse/README.md index e72bb1809..82b50d63c 100644 --- a/src/collapse/README.md +++ b/src/collapse/README.md @@ -126,3 +126,11 @@ export default { | icon | Custom icon | | title | Custom title | | right-icon | Custom right icon | + +### CollapseItem Methods + +Use [ref](https://vuejs.org/v2/api/#ref) to get CollapseItem instance and call instance methods. + +| Name | Description | Attribute | Return value | +| --- | --- | --- | --- | +| toggle `v2.10.9` | Toggle expanded status | _expanded: boolean_ | - | diff --git a/src/collapse/README.zh-CN.md b/src/collapse/README.zh-CN.md index f67dc534e..496b781f5 100644 --- a/src/collapse/README.zh-CN.md +++ b/src/collapse/README.zh-CN.md @@ -117,10 +117,18 @@ export default { ### CollapseItem Slots -| 名称 | 说明 | -| ---------- | ----------------------------- | -| default | 面板内容 | -| value | 自定义显示内容 | -| icon | 自定义`icon` | -| title | 自定义`title` | -| right-icon | 自定义右侧按钮,默认是`arrow` | +| 名称 | 说明 | +| ---------- | ------------------------------ | +| default | 面板内容 | +| value | 自定义显示内容 | +| icon | 自定义 `icon` | +| title | 自定义 `title` | +| right-icon | 自定义右侧按钮,默认是 `arrow` | + +### CollapseItem 方法 + +通过 ref 可以获取到 CollapseItem 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 + +| 方法名 | 说明 | 参数 | 返回值 | +| --- | --- | --- | --- | +| toggle `v2.10.9` | 切换面试展开状态,传 `true` 为展开,`false` 为收起,不传参为切换 | _expand?: boolean_ | - | diff --git a/src/collapse/test/index.spec.js b/src/collapse/test/index.spec.js index 6702cd9d9..bc935f91d 100644 --- a/src/collapse/test/index.spec.js +++ b/src/collapse/test/index.spec.js @@ -144,3 +144,61 @@ test('warn when value type is incorrect', () => { expect(error).toHaveBeenCalledTimes(1); console.error = originConsoleError; }); + +test('toggle method', (done) => { + mount({ + template: ` + + + + + `, + data() { + return { active: [] }; + }, + mounted() { + this.$refs.a.toggle(); + expect(this.active).toEqual(['a']); + + this.$refs.b.toggle(); + expect(this.active).toEqual(['a', 'b']); + + this.$refs.b.toggle(false); + expect(this.active).toEqual(['a']); + + this.$refs.a.toggle(); + expect(this.active).toEqual([]); + + done(); + }, + }); +}); + +test('toggle method in accordion mode', (done) => { + mount({ + template: ` + + + + + `, + data() { + return { active: '' }; + }, + mounted() { + this.$refs.a.toggle(); + expect(this.active).toEqual('a'); + + this.$refs.b.toggle(); + expect(this.active).toEqual('b'); + + this.$refs.b.toggle(false); + expect(this.active).toEqual(''); + + this.$refs.a.toggle(); + expect(this.active).toEqual('a'); + + done(); + }, + }); +}); diff --git a/src/count-down/README.md b/src/count-down/README.md index d6240004e..99e5b7c46 100644 --- a/src/count-down/README.md +++ b/src/count-down/README.md @@ -156,7 +156,7 @@ export default { ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get CountDown instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get CountDown instance and call instance methods. | Name | Description | Attribute | Return value | | ----- | ---------------- | --------- | ------------ | diff --git a/src/count-down/README.zh-CN.md b/src/count-down/README.zh-CN.md index b37b30448..83444324c 100644 --- a/src/count-down/README.zh-CN.md +++ b/src/count-down/README.zh-CN.md @@ -166,7 +166,7 @@ export default { ### 方法 -通过 ref 可以获取到 CountDown 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 CountDown 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/src/datetime-picker/README.md b/src/datetime-picker/README.md index 872973140..0b2c4e23a 100644 --- a/src/datetime-picker/README.md +++ b/src/datetime-picker/README.md @@ -294,7 +294,7 @@ Following props are supported when the type is time ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get DatetimePicker instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get DatetimePicker instance and call instance methods. | Name | Description | Attribute | Return value | | ------------------ | ------------------- | --------- | ------------ | diff --git a/src/datetime-picker/README.zh-CN.md b/src/datetime-picker/README.zh-CN.md index 4b2dda45e..04f5c4b5e 100644 --- a/src/datetime-picker/README.zh-CN.md +++ b/src/datetime-picker/README.zh-CN.md @@ -303,7 +303,7 @@ export default { ### 方法 -通过 ref 可以获取到 DatetimePicker 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 DatetimePicker 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/src/dropdown-menu/README.md b/src/dropdown-menu/README.md index f39fe3cf8..d7c7e71fb 100644 --- a/src/dropdown-menu/README.md +++ b/src/dropdown-menu/README.md @@ -163,11 +163,11 @@ Use `active-color` prop to custom active color of the title and options. ### DropdownItem Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get DropdownItem instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get DropdownItem instance and call instance methods. -| Name | Description | Attribute | Return value | -| ------ | -------------- | ------------- | ------------ | -| toggle | Toggle display | show: boolean | - | +| Name | Description | Attribute | Return value | +| ------ | -------------- | --------------- | ------------ | +| toggle | Toggle display | _show: boolean_ | - | ### Data Structure of Option diff --git a/src/dropdown-menu/README.zh-CN.md b/src/dropdown-menu/README.zh-CN.md index 8e4424f3d..3c0a72c9b 100644 --- a/src/dropdown-menu/README.zh-CN.md +++ b/src/dropdown-menu/README.zh-CN.md @@ -167,11 +167,11 @@ export default { ### DropdownItem 方法 -通过 ref 可以获取到 DropdownItem 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 DropdownItem 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | -| toggle | 切换菜单展示状态,传`true`为显示,`false`为隐藏,不传参为取反 | show?: boolean | - | +| toggle | 切换菜单展示状态,传 `true` 为显示,`false` 为隐藏,不传参为取反 | _show?: boolean_ | - | ### Option 数据结构 diff --git a/src/field/README.md b/src/field/README.md index 62fd6bd46..43261bdbf 100644 --- a/src/field/README.md +++ b/src/field/README.md @@ -270,7 +270,7 @@ Field support all native events of input tag ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Field instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get Field instance and call instance methods. | Name | Description | Attribute | Return value | | ----- | ------------------- | --------- | ------------ | diff --git a/src/field/README.zh-CN.md b/src/field/README.zh-CN.md index 6ec7a7e4e..242b745f0 100644 --- a/src/field/README.zh-CN.md +++ b/src/field/README.zh-CN.md @@ -295,7 +295,7 @@ export default { ### 方法 -通过 ref 可以获取到 Field 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 Field 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | ------ | -------------- | ---- | ------ | diff --git a/src/form/README.md b/src/form/README.md index 5d0330f07..e90b9ff37 100644 --- a/src/form/README.md +++ b/src/form/README.md @@ -467,7 +467,7 @@ export default { ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Form instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get Form instance and call instance methods. | Name | Description | Attribute | Return value | | --- | --- | --- | --- | diff --git a/src/form/README.zh-CN.md b/src/form/README.zh-CN.md index da43df78f..8722be87f 100644 --- a/src/form/README.zh-CN.md +++ b/src/form/README.zh-CN.md @@ -508,7 +508,7 @@ export default { ### 方法 -通过 ref 可以获取到 Form 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 Form 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/src/list/README.md b/src/list/README.md index b2b0f31a5..71e7e68b4 100644 --- a/src/list/README.md +++ b/src/list/README.md @@ -162,7 +162,7 @@ export default { ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get List instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get List instance and call instance methods. | Name | Description | Attribute | Return value | | ----- | --------------------- | --------- | ------------ | diff --git a/src/list/README.zh-CN.md b/src/list/README.zh-CN.md index bb1165031..6d50869b0 100644 --- a/src/list/README.zh-CN.md +++ b/src/list/README.zh-CN.md @@ -177,7 +177,7 @@ export default { ### 方法 -通过 ref 可以获取到 List 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 List 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/src/picker/README.md b/src/picker/README.md index f25ea24fc..13cdabbf7 100644 --- a/src/picker/README.md +++ b/src/picker/README.md @@ -287,7 +287,7 @@ Picker events will pass different parameters according to the columns are single ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Picker instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get Picker instance and call instance methods. | Name | Description | Attribute | Return value | | --- | --- | --- | --- | diff --git a/src/picker/README.zh-CN.md b/src/picker/README.zh-CN.md index 22bcf5e29..5274f0f39 100644 --- a/src/picker/README.zh-CN.md +++ b/src/picker/README.zh-CN.md @@ -312,7 +312,7 @@ export default { ### 方法 -通过 ref 可以获取到 Picker 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 Picker 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/src/sku/README.md b/src/sku/README.md index 73e64d92d..179e99240 100644 --- a/src/sku/README.md +++ b/src/sku/README.md @@ -157,7 +157,7 @@ export default { ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Sku instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get Sku instance and call instance methods. | Name | Description | Attribute | Return value | | --- | --- | --- | --- | diff --git a/src/sku/README.zh-CN.md b/src/sku/README.zh-CN.md index 686de63c4..dca1ce63c 100644 --- a/src/sku/README.zh-CN.md +++ b/src/sku/README.zh-CN.md @@ -162,7 +162,7 @@ export default { ### 方法 -通过 ref 可以获取到 Sku 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 Sku 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | ------------------------- | ---------------------- | ---- | ------- | diff --git a/src/swipe-cell/README.md b/src/swipe-cell/README.md index 2ccdebf67..16762f6e3 100644 --- a/src/swipe-cell/README.md +++ b/src/swipe-cell/README.md @@ -131,7 +131,7 @@ export default { ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get SwipeCell instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get SwipeCell instance and call instance methods. | Name | Description | Attribute | Return value | | ----- | --------------- | ------------------------ | ------------ | diff --git a/src/swipe-cell/README.zh-CN.md b/src/swipe-cell/README.zh-CN.md index 66b62c287..11ae45774 100644 --- a/src/swipe-cell/README.zh-CN.md +++ b/src/swipe-cell/README.zh-CN.md @@ -141,7 +141,7 @@ beforeClose 的第一个参数为对象,对象中包含以下属性: ### 方法 -通过 ref 可以获取到 SwipeCell 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 SwipeCell 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | ------ | ---------------- | ------------------------ | ------ | diff --git a/src/swipe/README.md b/src/swipe/README.md index 329757768..c1a3daef5 100644 --- a/src/swipe/README.md +++ b/src/swipe/README.md @@ -187,7 +187,7 @@ export default { ### Swipe Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Swipe instance and call instance methods. +Use [ref](https://vuejs.org/v2/api/#ref) to get Swipe instance and call instance methods.. | Name | Description | Attribute | Return value | | --- | --- | --- | --- | diff --git a/src/swipe/README.zh-CN.md b/src/swipe/README.zh-CN.md index 4834dccb9..00febc693 100644 --- a/src/swipe/README.zh-CN.md +++ b/src/swipe/README.zh-CN.md @@ -193,7 +193,7 @@ export default { ### Swipe 方法 -通过 ref 可以获取到 Swipe 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 +通过 ref 可以获取到 Swipe 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/src/tab/README.md b/src/tab/README.md index e78980f12..a0bf32707 100644 --- a/src/tab/README.md +++ b/src/tab/README.md @@ -265,7 +265,7 @@ export default { ### Tabs Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Tabs instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get Tabs instance and call instance methods. | Name | Description | Attribute | Return value | | --- | --- | --- | --- | diff --git a/src/tab/README.zh-CN.md b/src/tab/README.zh-CN.md index 77a10cb63..1df713497 100644 --- a/src/tab/README.zh-CN.md +++ b/src/tab/README.zh-CN.md @@ -273,7 +273,7 @@ export default { ### Tabs 方法 -通过 ref 可以获取到 Tabs 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 Tabs 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/src/uploader/README.md b/src/uploader/README.md index e5f2c39c4..d7531e2a2 100644 --- a/src/uploader/README.md +++ b/src/uploader/README.md @@ -253,7 +253,7 @@ Use `disabled` prop to disable uploader. ### Methods -Use [ref](https://vuejs.org/v2/api/#ref) to get Uploader instance and call instance methods +Use [ref](https://vuejs.org/v2/api/#ref) to get Uploader instance and call instance methods. | Name | Description | Attribute | Return value | | --- | --- | --- | --- | diff --git a/src/uploader/README.zh-CN.md b/src/uploader/README.zh-CN.md index add7f93ec..e1188659e 100644 --- a/src/uploader/README.zh-CN.md +++ b/src/uploader/README.zh-CN.md @@ -281,7 +281,7 @@ before-read、after-read、before-delete 执行时会传递以下回调参数: ### 方法 -通过 ref 可以获取到 Uploader 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) +通过 ref 可以获取到 Uploader 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa)。 | 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | diff --git a/types/collapse-item.d.ts b/types/collapse-item.d.ts new file mode 100644 index 000000000..092e80e72 --- /dev/null +++ b/types/collapse-item.d.ts @@ -0,0 +1,5 @@ +import { VanComponent } from './component'; + +export class CollapseItem extends VanComponent { + toggle(expanded?: boolean): void; +} diff --git a/types/index.d.ts b/types/index.d.ts index d3b02188b..38a46936a 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -6,6 +6,7 @@ import { Area } from './area'; import { Calendar } from './calendar'; import { Checkbox } from './checkbox'; import { CheckboxGroup } from './checkbox-group'; +import { CollapseItem } from './collapse-item'; import { CountDown } from './count-down'; import { DatetimePicker } from './datetime-picker'; import { Dialog } from './dialog'; @@ -37,7 +38,6 @@ export class CellGroup extends VanComponent {} export class Circle extends VanComponent {} export class Col extends VanComponent {} export class Collapse extends VanComponent {} -export class CollapseItem extends VanComponent {} export class ContactCard extends VanComponent {} export class ContactEdit extends VanComponent {} export class ContactList extends VanComponent {} @@ -97,6 +97,7 @@ export { Calendar, Checkbox, CheckboxGroup, + CollapseItem, CountDown, DatetimePicker, Dialog,