import type { PropType } from 'vue' import { computed, defineComponent, ref } from 'vue' import { getPrefixCls } from '../_utils/getPrefixCls' import Icon from '../icon' export default defineComponent({ name: 'Input', props: { modelValue: String, size: { type: String as PropType<'small' | 'medium' | 'large'>, default: 'medium', }, align: { type: String as PropType<'left' | 'center' | 'right'>, default: 'left', }, placeholder: String, disabled: Boolean, readonly: Boolean, clearable: Boolean, prefixIcon: String, suffixIcon: String, showCount: Boolean, maxlength: Number, password: Boolean, prepend: String, append: String, }, emits: ['update:modelValue'], setup(props, { slots, emit }) { const prefixCls = getPrefixCls('input') const inputValue = ref(props.modelValue || '') // 控制密码显示/隐藏 const showPassword = ref(false) const updateValue = (val: string) => { if (props.maxlength) val = val.slice(0, props.maxlength) inputValue.value = val emit('update:modelValue', val) } const countText = computed(() => { const len = inputValue.value.length return props.maxlength ? `${len} / ${props.maxlength}` : `${len}` }) const inputType = computed(() => { if (!props.password) return 'text' return showPassword.value ? 'text' : 'password' }) const inputWrapper = () => { return (