refactor(DatePicker): refactor with composition api

This commit is contained in:
chenjiahan
2020-09-27 16:30:35 +08:00
parent 486ad58042
commit 6388423c96
3 changed files with 195 additions and 208 deletions
+3 -3
View File
@@ -12,16 +12,16 @@ export default createComponent({
...DatePicker.props,
},
setup(props) {
setup(props, { attrs }) {
const root = ref();
useExpose({
getPicker: () => root.value && root.value.getPicker(),
getPicker: () => root.value?.getPicker(),
});
return () => {
const Component = props.type === 'time' ? TimePicker : DatePicker;
return <Component ref={root} class={bem()} {...props} />;
return <Component ref={root} class={bem()} {...{ ...props, ...attrs }} />;
};
},
});