feat(Picker): add getSelectedOptions method

This commit is contained in:
chenjiahan 2022-02-16 12:00:32 +08:00
parent e2790fe95d
commit 83295e655d
4 changed files with 12 additions and 7 deletions

View File

@ -285,7 +285,9 @@ export default defineComponent({
{ immediate: true } { immediate: true }
); );
useExpose<PickerExpose>({ confirm }); const getSelectedOptions = () => selectedOptions.value;
useExpose<PickerExpose>({ confirm, getSelectedOptions });
return () => ( return () => (
<div class={bem()}> <div class={bem()}>

View File

@ -355,9 +355,10 @@ export default {
Use [ref](https://v3.vuejs.org/guide/component-template-refs.html) to get Picker instance and call instance methods. Use [ref](https://v3.vuejs.org/guide/component-template-refs.html) to get Picker instance and call instance methods.
| Name | Description | Attribute | Return value | | Name | Description | Attribute | Return value |
| ------- | ------------------------------------- | --------- | ------------ | | --- | --- | --- | --- |
| confirm | Stop scrolling and emit confirm event | - | - | | confirm | Stop scrolling and emit confirm event | - | - |
| getSelectedOptions | Get current selected options | - | _PickerOption[]_ |
### Types ### Types

View File

@ -374,9 +374,10 @@ export default {
通过 ref 可以获取到 Picker 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)。 通过 ref 可以获取到 Picker 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)。
| 方法名 | 说明 | 参数 | 返回值 | | 方法名 | 说明 | 参数 | 返回值 |
| ------- | --------------------------------- | ---- | ------ | | --- | --- | --- | --- |
| confirm | 停止惯性滚动并触发 `confirm` 事件 | - | - | | confirm | 停止惯性滚动并触发 `confirm` 事件 | - | - |
| getSelectedOptions | 获取当前选中的选项 | - | _PickerOption[]_ |
### 类型定义 ### 类型定义

View File

@ -24,6 +24,7 @@ export type PickerColumn = PickerOption[];
export type PickerExpose = { export type PickerExpose = {
confirm: () => void; confirm: () => void;
getSelectedOptions: () => PickerOption[];
}; };
export type PickerColumnProvide = { export type PickerColumnProvide = {