UNPKG

vxe-table-demonic

Version:

一个基于 vue 的 PC 端表单/表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式...

39 lines (32 loc) 1.29 kB
import { defineComponent, h, onUnmounted, inject, ref, Ref, onMounted, PropType } from 'vue' import { XEOptionProvide, createOption, watchOption, destroyOption, assemOption } from './util' import { VxeSelectConstructor, VxeOptionPropTypes } from '../../../types/all' export default defineComponent({ name: 'VxeOption', props: { value: null, label: { type: [String, Number, Boolean] as PropType<VxeOptionPropTypes.Label>, default: '' }, visible: { type: Boolean as PropType<VxeOptionPropTypes.Visible>, default: null }, className: [String, Function] as PropType<VxeOptionPropTypes.ClassName>, disabled: Boolean as PropType<VxeOptionPropTypes.Disabled> }, setup (props, { slots }) { const elem = ref() as Ref<HTMLDivElement> const $xeselect = inject('$xeselect', {} as VxeSelectConstructor) const optgroup = inject('xeoptgroup', null as XEOptionProvide | null) const option = createOption($xeselect, props) option.slots = slots watchOption(props, option) onMounted(() => { assemOption($xeselect, elem.value, option, optgroup) }) onUnmounted(() => { destroyOption($xeselect, option) }) return () => { return h('div', { ref: elem }) } } })