diff --git a/components.js b/components.js index 5a02e8202..5169725a9 100644 --- a/components.js +++ b/components.js @@ -43,4 +43,5 @@ module.exports = [ 'tab', 'tabs', 'sticky', + 'picker', ]; diff --git a/src/picker/PickerColumn.js b/src/picker/PickerColumn.js index 758558389..195c0c3d1 100644 --- a/src/picker/PickerColumn.js +++ b/src/picker/PickerColumn.js @@ -43,6 +43,8 @@ export default createComponent({ }, }, + emits: ['change'], + data() { return { offset: 0, @@ -266,28 +268,22 @@ export default createComponent({ const data = { style: optionStyle, - attrs: { - role: 'button', - tabindex: disabled ? -1 : 0, - }, + role: 'button', + tabindex: disabled ? -1 : 0, class: [ bem('item', { disabled, selected: index === this.currentIndex, }), ], - on: { - click: () => { - this.onClickItem(index); - }, + onClick: () => { + this.onClickItem(index); }, }; const childData = { class: 'van-ellipsis', - domProps: { - [this.allowHtml ? 'innerHTML' : 'textContent']: text, - }, + [this.allowHtml ? 'innerHTML' : 'textContent']: text, }; return ( diff --git a/src/picker/demo/index.vue b/src/picker/demo/index.vue index a275b02bf..d4734be36 100644 --- a/src/picker/demo/index.vue +++ b/src/picker/demo/index.vue @@ -62,14 +62,14 @@ - + - {this.slots() || [ - , - this.genTitle(), - , - ]} + {this.$slots.default + ? this.$slots.default() + : [ + , + this.genTitle(), + , + ]} ); } @@ -339,15 +347,15 @@ export default createComponent({ }, }, - render(h) { + render() { return (
- {this.toolbarPosition === 'top' ? this.genToolbar() : h()} - {this.loading ? : h()} - {this.slots('columns-top')} + {this.toolbarPosition === 'top' ? this.genToolbar() : null} + {this.loading ? : null} + {this.$slots['columns-top']?.()} {this.genColumns()} - {this.slots('columns-bottom')} - {this.toolbarPosition === 'bottom' ? this.genToolbar() : h()} + {this.$slots['columns-bottom']?.()} + {this.toolbarPosition === 'bottom' ? this.genToolbar() : null}
); }, diff --git a/vant.config.js b/vant.config.js index 5753c0f74..5553be02e 100644 --- a/vant.config.js +++ b/vant.config.js @@ -143,10 +143,10 @@ module.exports = { // path: 'password-input', // title: 'PasswordInput 密码输入框', // }, - // { - // path: 'picker', - // title: 'Picker 选择器', - // }, + { + path: 'picker', + title: 'Picker 选择器', + }, // { // path: 'radio', // title: 'Radio 单选框', @@ -477,10 +477,10 @@ module.exports = { // path: 'password-input', // title: 'PasswordInput', // }, - // { - // path: 'picker', - // title: 'Picker', - // }, + { + path: 'picker', + title: 'Picker', + }, // { // path: 'radio', // title: 'Radio',