dm-vue3-ui
Version:
This Components Library will help get you started developing in Vue 3.
47 lines (46 loc) • 1.32 kB
JavaScript
import { Input } from "ant-design-vue/es";
import { defineComponent, ref, computed, openBlock, createBlock, nextTick } from "vue";
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "input",
props: {
data: { default: () => ({}) }
},
emits: ["apply"],
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const emit = __emit;
const value = ref("");
const placeholder = computed(() => {
if (props.data.placeholder) {
return props.data.placeholder;
} else {
return `输入${props.data.label}`;
}
});
const pressEnter = () => {
if (value.value !== "") {
let data = { field: props.data.field, value: value.value };
nextTick(() => {
value.value = "";
emit("apply", data);
});
}
};
__expose({
pressEnter
});
return (_ctx, _cache) => {
const _component_a_input = Input;
return openBlock(), createBlock(_component_a_input, {
bordered: false,
value: value.value,
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => value.value = $event),
placeholder: placeholder.value,
onPressEnter: pressEnter
}, null, 8, ["value", "placeholder"]);
};
}
});
export {
_sfc_main as default
};