Skip to content

CyberInput 输入框

赛博朋克风格的输入框组件,支持多种主题、尺寸和特效。

基础用法

vue
<template>
  <cyber-input v-model="value" placeholder="请输入内容"></cyber-input>
</template>

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

不同主题

组件支持 5 种主题样式:primarysuccesswarningdangerinfo

vue
<template>
  <cyber-input theme="primary" placeholder="主要主题"></cyber-input>
  <cyber-input theme="success" placeholder="成功主题"></cyber-input>
  <cyber-input theme="warning" placeholder="警告主题"></cyber-input>
  <cyber-input theme="danger" placeholder="危险主题"></cyber-input>
  <cyber-input theme="info" placeholder="信息主题"></cyber-input>
</template>

不同尺寸

支持 3 种尺寸:largedefaultsmall

vue
<template>
  <cyber-input size="large" placeholder="大尺寸"></cyber-input>
  <cyber-input size="default" placeholder="默认尺寸"></cyber-input>
  <cyber-input size="small" placeholder="小尺寸"></cyber-input>
</template>

禁用状态

vue
<template>
  <cyber-input disabled placeholder="禁用状态"></cyber-input>
</template>

只读状态

vue
<template>
  <cyber-input readonly model-value="只读内容"></cyber-input>
</template>

输入类型

支持多种输入类型:textpasswordnumberemailtelurl

vue
<template>
  <cyber-input type="password" placeholder="密码输入"></cyber-input>
  <cyber-input type="email" placeholder="邮箱输入"></cyber-input>
  <cyber-input type="number" placeholder="数字输入"></cyber-input>
</template>

最大长度限制

vue
<template>
  <cyber-input maxlength="10" placeholder="最多10个字符"></cyber-input>
</template>

特效控制

可以控制故障特效和扫描线特效的显示

vue
<template>
  <!-- 关闭故障特效 -->
  <cyber-input :glitch-effect="false" placeholder="无故障特效"></cyber-input>
  
  <!-- 关闭扫描线特效 -->
  <cyber-input :scanline-effect="false" placeholder="无扫描线特效"></cyber-input>
  
  <!-- 关闭所有特效 -->
  <cyber-input :glitch-effect="false" :scanline-effect="false" placeholder="无特效"></cyber-input>
</template>

API

Props

参数说明类型可选值默认值
modelValue / v-model绑定值string | number''
type输入框类型stringtext/password/number/email/tel/urltext
placeholder占位文本string'请输入...'
disabled是否禁用booleanfalse
readonly是否只读booleanfalse
maxlength最大输入长度string | numberundefined
autocomplete自动完成stringon/offoff
size输入框尺寸stringlarge/default/smalldefault
theme主题样式stringprimary/success/warning/danger/infoprimary
glitchEffect是否显示故障特效booleantrue
scanlineEffect是否显示扫描线特效booleantrue

Events

事件名说明回调参数
update:modelValue当绑定值变化时触发(value: string | number)
input输入时触发(value: string)
focus获得焦点时触发(event: FocusEvent)
blur失去焦点时触发(event: FocusEvent)
keyup键盘抬起时触发(event: KeyboardEvent)
keydown键盘按下时触发(event: KeyboardEvent)

Methods

方法名说明参数
focus使输入框获取焦点
blur使输入框失去焦点
select选中输入框中的文本

Slots

暂无

示例代码

完整的示例可以参考测试页面:test/src/conponents/input.vue

Relcased under the Mit Lincense.