UNPKG

@wfrog/vc

Version:

vue3 组件库 vc

33 lines (30 loc) 1.25 kB
import { defineComponent, computed, createBlock, openBlock, mergeProps, unref, isRef } from 'vue'; import { C as Component } from '../choice/choice.mjs'; import { u as useVModel } from '../../chunk/eQT9aAiW.mjs'; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "choice-boolean", props: { modelValue: { type: [Boolean, Array, Number] }, text: { default: () => ["是", "否"] }, valueType: { default: "boolean" } }, emits: ["update:modelValue"], setup(__props, { emit: __emit }) { const props = __props; const emits = __emit; const myValue = useVModel(props, "modelValue", emits); const [textTrue, textFalse] = props.text; const data = computed(() => [ { label: textTrue, value: props.valueType === "boolean" ? true : 1 }, { label: textFalse, value: props.valueType === "boolean" ? false : 0 } ]); return (_ctx, _cache) => { return openBlock(), createBlock(Component, mergeProps({ modelValue: unref(myValue), "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(myValue) ? myValue.value = $event : null), options: unref(data) }, _ctx.$attrs), null, 16, ["modelValue", "options"]); }; } }); export { _sfc_main as _ };