mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Picker): add confirm method
This commit is contained in:
parent
d7ae8c5a26
commit
5eb2a4012a
@ -241,3 +241,4 @@ Use [ref](https://vuejs.org/v2/api/#ref) to get Picker instance and call instanc
|
|||||||
| setColumnIndex | Set current index of the column | columnIndex, optionIndex | - |
|
| setColumnIndex | Set current index of the column | columnIndex, optionIndex | - |
|
||||||
| getColumnValues | Get columns data of the column | columnIndex | values |
|
| getColumnValues | Get columns data of the column | columnIndex | values |
|
||||||
| setColumnValues | Set columns data of the column | columnIndex, values | - |
|
| setColumnValues | Set columns data of the column | columnIndex, values | - |
|
||||||
|
| confirm | Stop scrolling and emit confirm event | - | - |
|
||||||
|
@ -253,6 +253,7 @@ Picker 组件的事件会根据 columns 是单列或多列返回不同的参数
|
|||||||
| setColumnIndex | 设置对应列选中项的索引 | columnIndex, optionIndex | - |
|
| setColumnIndex | 设置对应列选中项的索引 | columnIndex, optionIndex | - |
|
||||||
| getColumnValues | 获取对应列中所有选项 | columnIndex | values |
|
| getColumnValues | 获取对应列中所有选项 | columnIndex | values |
|
||||||
| setColumnValues | 设置对应列中所有选项 | columnIndex, values | - |
|
| setColumnValues | 设置对应列中所有选项 | columnIndex, values | - |
|
||||||
|
| confirm | 停止惯性滚动并触发 confirm 事件 | - | - |
|
||||||
|
|
||||||
## 常见问题
|
## 常见问题
|
||||||
|
|
||||||
|
@ -153,12 +153,13 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onConfirm() {
|
// @exposed-api
|
||||||
this.children.map(child => child.stopMomentum());
|
confirm() {
|
||||||
|
this.children.forEach(child => child.stopMomentum());
|
||||||
this.emit('confirm');
|
this.emit('confirm');
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancel() {
|
cancel() {
|
||||||
this.emit('cancel');
|
this.emit('cancel');
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -182,7 +183,7 @@ export default createComponent({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class={bem('cancel')}
|
class={bem('cancel')}
|
||||||
onClick={this.onCancel}
|
onClick={this.cancel}
|
||||||
>
|
>
|
||||||
{this.cancelButtonText || t('cancel')}
|
{this.cancelButtonText || t('cancel')}
|
||||||
</button>,
|
</button>,
|
||||||
@ -190,7 +191,7 @@ export default createComponent({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class={bem('confirm')}
|
class={bem('confirm')}
|
||||||
onClick={this.onConfirm}
|
onClick={this.confirm}
|
||||||
>
|
>
|
||||||
{this.confirmButtonText || t('confirm')}
|
{this.confirmButtonText || t('confirm')}
|
||||||
</button>
|
</button>
|
||||||
|
2
types/picker.d.ts
vendored
2
types/picker.d.ts
vendored
@ -20,4 +20,6 @@ export class Picker extends VanComponent {
|
|||||||
getColumnValues(columnIndex: number): string[];
|
getColumnValues(columnIndex: number): string[];
|
||||||
|
|
||||||
setColumnValues(columnIndex: number, values: string[]): void;
|
setColumnValues(columnIndex: number, values: string[]): void;
|
||||||
|
|
||||||
|
confirm(): void;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user