mt-ui-components-vue3
Version:
玛果添实UI组件库(Vue3)
83 lines • 3.06 kB
JavaScript
/* Analyzed bindings: {
"trueText": "props",
"falseText": "props",
"trueValue": "props",
"falseValue": "props",
"Select": "setup-maybe-ref",
"SelectOption": "setup-maybe-ref",
"selectProps": "setup-maybe-ref",
"watch": "setup-const",
"ref": "setup-const",
"isBoolean": "setup-maybe-ref",
"props": "setup-reactive-const",
"myValue": "setup-ref"
} */
import { defineComponent as _defineComponent } from 'vue';
import { toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, unref as _unref, withCtx as _withCtx, createVNode as _createVNode, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock } from "vue";
import { Select, SelectOption } from 'ant-design-vue';
import { selectProps } from 'ant-design-vue/lib/select';
import { watch, ref } from 'vue';
import { isBoolean } from 'lodash-es';
const __sfc_main__ = _defineComponent({
props: {
...selectProps(),
trueText: {
type: String,
default: '是',
},
falseText: {
type: String,
default: '否',
},
trueValue: {
type: [String, Boolean, Number],
default: true,
},
falseValue: {
type: [String, Boolean, Number],
default: false,
},
},
setup(__props) {
const props = __props;
const myValue = ref();
watch(() => props.value, () => {
if (isBoolean(props.value)) {
myValue.value = `${props.value}`;
}
else {
myValue.value = props.value;
}
}, { immediate: true });
return (_ctx, _cache) => {
return (_openBlock(), _createBlock(_unref(Select), _mergeProps(props, {
value: myValue.value,
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => ((myValue).value = $event)),
onSelect: _ctx.select
}), {
default: _withCtx(() => [
_createVNode(_unref(SelectOption), {
key: "true",
value: __props.trueValue
}, {
default: _withCtx(() => [
_createTextVNode(_toDisplayString(__props.trueText), 1 /* TEXT */)
]),
_: 1 /* STABLE */
}, 8 /* PROPS */, ["value"]),
_createVNode(_unref(SelectOption), {
key: "false",
value: __props.falseValue
}, {
default: _withCtx(() => [
_createTextVNode(_toDisplayString(__props.falseText), 1 /* TEXT */)
]),
_: 1 /* STABLE */
}, 8 /* PROPS */, ["value"])
]),
_: 1 /* STABLE */
}, 16 /* FULL_PROPS */, ["value", "onSelect"]));
};
}
});
export default __sfc_main__;