Skip to content

Input

输入框组件,用于用户输入文本信息。

基础用法

js
<script setup>
    import { ref } from 'vue'
    const msg = ref('')
</script>

<template>
  <m-input v-model="msg" placeholder="Please enter text"></m-input>
</template>

前缀与后缀

Prefix
suffix
js
<template>
    <m-input v-model="msg" placeholder="Please enter text" prefix="Prefix"></m-input>
    <m-input v-model="msg" placeholder="Please enter text" suffix="suffix"></m-input>
</template>

前置内容与后置内容

prepend
append
js
<template>
    <m-input v-model="msg" placeholder="Please enter text" prepend="prepend"></m-input>
    <m-input v-model="msg" placeholder="Please enter text" append="append"></m-input>
</template>

禁用状态

js
<template>
   <m-input v-model="msg" placeholder="Please enter text" disabled></m-input>
</template>

只读状态

js
<template>
   <m-input v-model="msg" placeholder="Please enter text" readonly></m-input>
</template>

尺寸

尺寸取值: minismalllarge, Default small

js
<template>
   <m-input v-model="msg" placeholder="Please enter text" size="large"></m-input>
</template>

可清除功能

js
<template>
   <m-input v-model="msg" placeholder="Please enter text" clearable></m-input>
</template>

密码类型

js
<template>
   <m-input v-model="msg" type="password" showPasswordIcon placeholder="Please enter text" show-password></m-input>
</template>

字符限制数量

0/10
js
<template>
   <m-input v-model="msg" placeholder="Please enter text" :maxlength="10" showLimitCount></m-input>
</template>

API

PropertyDescriptionTypeDefault
v-model绑定的值string-
value绑定的值string-
typeInput box typestringtext
placeholderPlaceholder textstring-
disabledDisabled state of input boxbooleanfalse
readonlyReadonly state of input boxbooleanfalse
sizeSize of input box, optional values: minismalllargestringsmall
showPasswordIconShow password iconbooleanfalse
showLimitCountShow limit countbooleanfalse
maxLengthMaximum number of characters allowednumber-
prependPrepend slotstring-
appendAppend slotstring-
prefixPrefix slotstring-
suffixSuffix slotstring-
clearableWhether to show the clear buttonbooleanfalse

Events

Event NameDescriptionParameters
changeTriggered when the value changes(value: string)
focusTriggered when the input box gets focus(event: Event)
blurTriggered when the input box loses focus(event: Event)

Slots

NameDescription
prependPrepend slot
appendAppend slot
prefixPrefix slot
suffixSuffix slot

Released under the MIT License.