Input 输入框
通过鼠标或键盘输入字符,基于 el-input 封装,API 完全兼容。
基础用法
查看代码
vue
<script setup>
import { ref } from 'vue'
const text = ref('')
</script>
<template>
<MgInput v-model="text" placeholder="请输入内容" />
</template>禁用状态
查看代码
vue
<template>
<MgInput v-model="text" placeholder="禁用状态" disabled />
</template>可清空
查看代码
vue
<template>
<MgInput v-model="text" placeholder="可清空" clearable />
</template>文本域
查看代码
vue
<script setup>
import { ref } from 'vue'
const textarea = ref('')
</script>
<template>
<MgInput v-model="textarea" type="textarea" :rows="3" placeholder="多行输入" />
</template>Attributes
继承 Element Plus Input 的全部 Attributes。
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| type | 类型 | 'text' | 'textarea' | text |
| placeholder | 占位文本 | string | - |
| disabled | 是否禁用 | boolean | false |
| clearable | 可清空 | boolean | false |
| maxlength | 最大长度 | number | - |
差异
MgInput 在 el-input 基础上追加 .mg-input 类名;其余行为一致,迁移仅需将 el-input 替换为 MgInput,并支持 prefix/suffix/prepend/append 等具名插槽透传。