Skip to content

Input 输入框

WD UI 输入框组件,支持多种输入类型和样式。

基本使用

vue
<template>
  <view class="demo-block">
    <wd-input v-model="value" placeholder="请输入内容" />
  </view>
</template>

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

输入类型

vue
<template>
  <view class="demo-block">
    <!-- 文本输入 -->
    <wd-input v-model="text" type="text" placeholder="文本输入" />
    
    <!-- 数字输入 -->
    <wd-input v-model="number" type="number" placeholder="数字输入" />
    
    <!-- 密码输入 -->
    <wd-input v-model="password" type="password" placeholder="密码输入" />
    
    <!-- 手机号输入 -->
    <wd-input v-model="phone" type="tel" placeholder="手机号输入" />
  </view>
</template>

<script setup>
import { ref } from 'vue'
const text = ref('')
const number = ref('')
const password = ref('')
const phone = ref('')
</script>

API

Props

参数说明类型默认值
v-model输入值string/number
type输入类型stringtext
placeholder占位文本string
disabled是否禁用booleanfalse
readonly是否只读booleanfalse
clearable是否显示清空按钮booleanfalse
show-password是否显示密码切换按钮booleanfalse
maxlength最大输入长度number

Events

事件名说明参数
input输入时触发value
change值改变时触发value
focus获得焦点时触发event
blur失去焦点时触发event
clear点击清空按钮时触发