提交 b1bf146f 编写于 作者: 雪洛's avatar 雪洛

feat(harmony): 支持pick组件

上级 f0218e34
import { type ExtractPropTypes, ref } from 'vue'
import { defineBuiltInComponent } from '@dcloudio/uni-components'
import {
type EmitEvent,
defineBuiltInComponent,
useCustomEvent,
} from '@dcloudio/uni-components'
import Embed from '../embed'
type Mode = 'selector' | 'multiSelector' | 'time' | 'date'
......@@ -103,20 +107,30 @@ export default /*#__PURE__*/ defineBuiltInComponent({
props,
emits: ['change', 'cancel', 'columnchange'],
setup(props, { emit }) {
const rootRef = ref<HTMLElement | null>(null)
const embedRef = ref<InstanceType<typeof Embed> | null>(null)
const trigger = useCustomEvent<EmitEvent<typeof emit>>(rootRef, emit)
function onClick() {
// @ts-expect-error
embedRef.value!.click()
}
function onCancel(event: CustomEvent<any>) {
console.log('TODO onCancel:', event)
trigger('cancel', event, event.detail)
}
function onColumnchange(event: CustomEvent<any>) {
trigger('columnchange', event, event.detail)
}
function onChange(event: CustomEvent<any>) {
trigger('change', event, event.detail)
}
return () => (
<uni-picker>
<uni-picker ref={rootRef}>
<Embed
ref={embedRef}
tag="picker"
options={props}
onChange={onChange}
onColumnchange={onColumnchange}
onCancel={onCancel}
/>
<div onClick={onClick} class="uni-picker-slot"></div>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册