VInput.vue
1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<template>
<!--
二次封装:
- 统一样式类 v-input
- 支持 block(全宽)
-->
<ElInput class="v-input"
:class="[{ 'v-input--block': !!props.block }]"
:clearable="props.clearable"
:disabled="props.disabled"
:model-value="props.modelValue"
:placeholder="props.placeholder"
:type="props.type"
v-bind="$attrs"
@update:model-value="emit('update:modelValue', $event)">
<template #prepend>
<slot name="prepend" />
</template>
<template #append>
<slot name="append" />
</template>
<template #prefix>
<slot name="prefix" />
</template>
<template #suffix>
<slot name="suffix" />
</template>
</ElInput>
</template>
<script setup lang="ts">
import { ElInput } from "element-plus";
const props = defineProps<{
block?: boolean;
clearable?: boolean;
disabled?: boolean;
modelValue?: number | string;
placeholder?: string;
type?: string;
}>();
const emit = defineEmits([ "update:modelValue" ]);
</script>
<style scoped>
.v-input {
/* 可以在此定制输入框的默认样式 */
}
.v-input--block {
display: block;
}
</style>