更新记录

0.2.6(2026-09-01) 下载此版本

  • 修复 modelValue 被外部置 null 时崩溃(Cannot read property length of null):useStorage 置 null 删除 key 等场景下 v-model 传入 null,innerValue 在初始化与 modelValue watch 双入口统一规整为空串,保证内部 .length 访问与原生 value 绑定安全;外部置 null 显示为空串(同清空语义),其它行为不变

0.2.5(2026-08-31) 下载此版本

  • 聚焦指令位与触摸预亮状态机重构:innerFocus 真实失焦复位(不再依赖 blur 时序推断)、touchmove / touchcancel 撤回预亮(长按滚动列表不残留聚焦样式)
  • 清除 / 密码可见按钮 Web 端 mousedown 阻止先失焦(#ifdef WEB 条件编译),点击按钮不清除聚焦样式;其它端行为不变

0.2.4(2026-08-27) 下载此版本

  • 修复聚焦样式与实际焦点状态不同步:
    • 点击清除/密码可见按钮不再写死聚焦态:真实聚焦的输入框点击清除后保持聚焦样式(App 端点击按钮不失焦),已失焦的输入框(多输入框场景)点击清除不会被点亮
    • 根节点 touchstart 提前点亮聚焦样式,消除 App 端聚焦回调随键盘动画延迟导致的样式晚亮(约半秒)
    • 失焦样式同步清除,移除 onBlur 150ms 延迟,切换输入框时样式即时消失
查看更多

平台兼容性

uni-app x(4.25)

Chrome Safari Android iOS 鸿蒙 微信小程序

其他

多语言 暗黑模式 宽屏模式
× ×

nax-input

uni-app x 单行输入框。

依赖

  • nax-icon(清除 / 密码可见 / 前后缀图标)
  • nax-ui-theme(CSS 变量 --nax-*,安装时依赖 / 运行时弱依赖)

基础用法

<nax-input v-model="value" border placeholder="请输入内容"></nax-input>

<!-- 仅下边框 -->
<nax-input v-model="value" border border-type="bottom" placeholder="下划线风格"></nax-input>

类型 type

说明
text 文本(默认)
password 密码(可配 password-icon 切换可见)
number 数字键盘
digit 带小数点数字键盘
tel 电话键盘
email / url / nickname / safe-password / none 透传原生 input type

传入 select / textarea / idcard 会回落为 text

常用 Props

属性 类型 默认 说明
modelValue string '' v-model
type string text 见上表
clearable boolean true 有内容时显示清除
input-align string left left / center / right
placeholder string 请输入内容 占位
disabled boolean false 禁用
readonly boolean false 只读
maxlength number 140 最大长度;-1 不限制
border boolean false 是否边框
border-type string surround surround 四边 / bottom 仅下边框
border-color string '' 边框色
background string '' 背景色;无边框默认透明,传入后生效
password-icon boolean true 密码可见切换
size string md sm / md / lg
height string '' 覆盖高度(数字按 px)
trim boolean true 失焦去首尾空格
confirm-type string done 键盘完成按钮文案
focus boolean false 自动聚焦
prefix-icon / suffix-icon string '' 前后缀图标名
custom-class string '' 根节点扩展 class

更多键盘相关:cursor-spacingselection-startselection-endconfirm-holdadjust-positionhold-keyboardplaceholder-style

事件

事件 说明
update:modelValue v-model
input 输入变化(当前值),输入过程中每次触发
change 失焦时内容与聚焦时不同才触发(当前值),对齐原生 input 语义
focus / blur 聚焦 / 失焦(当前值)
confirm 键盘完成(当前值)
click 点击
clear 点击清除

插槽

名称 说明
prefix 自定义前缀
suffix 自定义后缀

主题

通过 CSS 变量覆盖:

Token 用途
--nax-border-width 边框粗细
--nax-color-bg 背景色
--nax-color-bg-secondary 次级背景色
--nax-color-border 边框色
--nax-color-primary 主题主色
--nax-color-text 主文字色
--nax-color-text-disabled 禁用文字色
--nax-input-bg 输入框背景色
--nax-opacity-disabled 禁用透明度

平台说明

  • 基于原生 input,键盘类型随端能力差异以官方文档为准。
  • readonly 通过禁用原生编辑实现(样式弱于 disabled)。
  • Android 暗黑模式下跨组件 CSS 变量可能失效,请通过 custom-class 传入 nax-theme-dark

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。