qwewq
This commit is contained in:
@ -1,12 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="form-item-box" :style="{ width: width }">
|
<div class="form-item-box" :style="{ width: width }">
|
||||||
<el-date-picker style="width:100%" v-model="modelValue" type="date" v-bind="$attrs" @change="onInput" :placeholder="placeholder" :value-format="props.format"/>
|
<el-date-picker
|
||||||
|
style="width:100%"
|
||||||
|
v-model="localModelValue"
|
||||||
|
:type="props.type"
|
||||||
|
v-bind="$attrs"
|
||||||
|
@change="onInput"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
:value-format="props.format"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { COMPONENT_WIDTH } from "@/constant";
|
import { COMPONENT_WIDTH } from "@/constant";
|
||||||
import { ref, defineProps, defineEmits, defineExpose } from "vue";
|
import { ref, defineProps, defineEmits, defineExpose, computed } from "vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
//获取组件传值
|
//获取组件传值
|
||||||
placeholder: {
|
placeholder: {
|
||||||
@ -25,12 +34,21 @@ const props = defineProps({
|
|||||||
default: COMPONENT_WIDTH,
|
default: COMPONENT_WIDTH,
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
type: {
|
||||||
|
default: "date",
|
||||||
|
type: String
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const emits = defineEmits(["update:modelValue"]);
|
const emits = defineEmits(["update:modelValue"]);
|
||||||
|
|
||||||
|
// 使用计算属性处理双向绑定
|
||||||
|
const localModelValue = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (value) => emits("update:modelValue", value)
|
||||||
|
});
|
||||||
|
|
||||||
const onInput = (e) => {
|
const onInput = (e) => {
|
||||||
emits("update:modelValue", e);
|
emits("update:modelValue", e);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Reference in New Issue
Block a user