更新记录

0.1.0(2026-12-04) 下载此版本

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

本文件为唯一日志源,运行 npm run changelog:sync 可自动同步到插件根目录 uni_modules/xq-ui/changelog.md;CI 可用 npm run changelog:check 校验一致性。


平台兼容性

uni-app x(5.25)

Chrome Safari Android iOS 鸿蒙 微信小程序 支付宝小程序
√ - √ - - √ -

其他

多语言 暗黑模式 宽屏模式 蒸汽模式
√ √ × √

Xq UI X

基于 uni-app x 蒸汽模式 的 TS 组件库,全部自研、零第三方依赖,支持亮色 / 暗色主题与多语言(内置 zh-CN / en-US 语言包)。

当前版本 0.2.0:115 个组件目录全部完成并通过 Web + Android(蒸汽模式字节码)双端编译,0 CSS 警告;iOS / HarmonyOS / 微信 / 支付宝等小程序编译与真机验证待环境接入。

环境

  • HBuilderX ≥ 5.25
  • uni-app x 项目,蒸汽模式(manifest.json 中 "uni-app-x": { "vapor": true })
  • 仅支持 TS / JS,不支持 VDOM 模式与 UTS 强类型约束
  • 目标平台:Android、iOS、HarmonyOS(蒸汽模式);Web(H5)、微信 / 支付宝等小程序(VDOM)

安装

  1. 从 DCloud 插件市场导入本插件到项目的 uni_modules/xq-ui 目录(开源前可手动拷贝该目录)。
  2. 在 main.ts 中安装:
import App from './App.uvue'
import { createSSRApp } from 'vue'
// 必须使用命名导入
import { xqUi } from '@/uni_modules/xq-ui'

export function createApp() {
    const app = createSSRApp(App)
    app.use(xqUi, {
        debugMode: false,
        config: {
            unit: 'px', // 数字尺寸默认补的单位
        },
        theme: {
            // 不传 themes 时使用内置默认主题
            defaultDarkMode: 'auto', // auto | light | dark
            isForce: false, // true 时每次启动都强制使用默认配置(忽略本地已保存)
        },
        locale: {
            defaultLocale: 'zh-CN', // 内置 zh-CN / en-US,也可传入自定义语言包
        },
    })
    return { app }
}
  1. 在 App.uvue 中引入主题变量并初始化主题:
<script setup>
    import { initTheme } from '@/uni_modules/xq-ui'

    onLaunch(() => {
        initTheme()
    })
</script>

<style lang="scss">
    @import '@/uni_modules/xq-ui/theme/index.scss';
</style>
  1. 组件按 easycom 规范自动注册,模板里直接使用:
<template>
    <xq-button type="primary">主要按钮</xq-button>
</template>

安装配置

app.use(xqUi, options) 的完整选项见 XqOptions 类型(import type { XqOptions } from '@/uni_modules/xq-ui')。

字段 类型 默认值 说明
debugMode boolean false 调试日志开关(开启后输出 [xq-ui] 前缀日志)
config.unit 'px' \| 'rpx' 'px' 数字尺寸默认补的单位
theme.themes XqTheme[] 内置默认主题 自定义主题列表
theme.defaultTheme string 首个主题 默认主题名
theme.defaultDarkMode 'auto' \| 'light' \| 'dark' 'auto' 首次启动使用的暗黑模式,auto 跟随系统
theme.isForce boolean false 是否每次启动都强制使用默认配置(忽略本地已保存值)
theme.globalCss GlobalCssOption - 全局注入的 CSS 变量
locale string \| XqLocale[] \| { locales?, defaultLocale?, isForce? } zh-CN 语言配置:内置 zh-CN / en-US,支持自定义语言包
locale.defaultLocale string 'zh-CN' 默认语言名(需存在于内置或自定义 locales 中)

类型导入

全部公共类型(含每个组件的 Props 与 expose 实例类型)从库根统一导入:

import type {
    XqButtonProps,
    XqButtonInstance,
    XqTheme,
    XqLocale,
    XqOptions,
} from '@/uni_modules/xq-ui'

国际化

内置 zh-CN / en-US 两套语言包,安装时通过 locale.defaultLocale 指定默认语言;组件文案(如上传、倒计时、校验提示)随语言自动切换。页面内可用 useLocale() 获取 t() 翻译函数与 setLocale() 切换语言(持久化到本地存储)。语言包键名由 XqLocaleKey 强类型约束,zh-CN / en-US 键结构严格对齐。

Composable

useTheme

import { useTheme } from '@/uni_modules/xq-ui'

const { themes, currentTheme, isDark, setTheme, setDarkMode, toggleDarkMode } = useTheme()
成员 类型 说明
themes Ref<XqTheme[]> 已注册主题列表
currentTheme Ref<XqTheme \| null> 当前主题(含 name/label/color)
isDark ComputedRef<boolean> 当前是否处于暗黑态
setTheme(name) (name: string) => void 切换主题并持久化
setDarkMode(mode) (mode: 'auto' \| 'light' \| 'dark') => void 设置暗黑模式并持久化
toggleDarkMode() () => void 在亮色与暗色之间切换(auto 视系统)

useToast

const { show, success, error, warning, info, loading, close } = useToast()
show('提交成功')
show({ title: '顶部提示', position: 'top' })

需要页面挂载 <xq-toast global /> 实例承接(demo-page 容器已内置);未挂载实例时自动回退官方 uni.showToast。loading 常驻需手动 close()。

useModal

const { show, confirm, close, clearLoading, confirmAsync, alertAsync } = useModal()
show({ content: '提示内容' })
const ok = await confirmAsync({ content: '确定删除吗?' })
if (ok) {
    // 确定
}

需要页面挂载 <xq-modal global /> 实例承接;未挂载实例时回退官方 uni.showModal。asyncClose: true 时确认按钮进入 loading,需手动 clearLoading() 收尾。

组件

通用属性:所有组件都支持 customStyle(根节点内联样式)与 customClass(根节点类名)。外间距请用 customStyle。

组件总览(115 个目录)

每个组件的完整 API 表(属性 / 事件 / 插槽 / expose)见示例工程 common/docs.ts,演示代码见 components/demo-<name>/。

分类 组件
基础 button / button-group / icon / tag / badge / divider / text / link / image / lazy-load / avatar / avatar-group / avatar-cropper
布局 row / col / cell / cell-group / card / grid / gap / section / sticky / status-bar / safe-bottom
导航 navbar / tabbar / tabs / subsection / index-list / index-item / dropdown / dropdown-item / dropdown-menu / tooltip / popconfirm / pagination / back-top / fab / root-portal
表单 input / input-otp / textarea / search / number-box / switch / checkbox / checkbox-group / radio / radio-group / slider / rate / picker / time-picker / time-select / select / tree-select / calendar / date-picker / date-picker-pane / keyboard / upload / verification-code / color-picker / color-picker-panel / form / form-item / transfer
反馈 toast / modal / action-sheet / popup / tour / tour-overlay / tour-step / mask / loading / loading-popup / skeleton / progress / circle-progress / notice-bar / steps / step / time-line / time-line-item / empty / no-network / alert-tips / top-tips / transition / read-more / count-down / count-to / statistic
数据 table / table-column / table-plus / td / th / tr / descriptions / descriptions-item / tree / qrcode / watermark / md-inline / file-preview / file-viewer
特殊 swiper / waterfall / collapse / collapse-item / full-screen / config-provider / signature

注:layout(栅格) 为示例工程的页面级演示(pages/layout/index,基于 xq-row / xq-col),不是组件目录。全部组件的完整文档见示例工程文档站与 common/docs.ts。

xq-button 按钮

API 设计。type/plain/hairline/loading 等为基础语义;text/bg/link/dashed/color/autoInsertSpace/nativeType 为扩展形态。

Props 类型 默认值 说明
type 'default' \| 'primary' \| 'success' \| 'warning' \| 'error' \| 'info' \| 'danger' 'default' 按钮类型,danger 为 error 别名
size 'large' \| 'normal' \| 'small' \| 'mini' 'normal' 按钮尺寸
shape 'round' \| 'square' \| 'circle' 'round' 按钮形状
plain boolean false 镂空(透明背景 + 类型色文字)
text boolean false 文字按钮:无边框背景,文字用类型色
bg boolean false 文字按钮是否显示浅色背景(仅 text 为 true 时生效)
link boolean false 链接按钮:无背景无边框
dashed boolean false 虚线边框(App-Android / 鸿蒙退化实线)
hairline boolean true 细边框;false 时边框加粗为 2px
borderRadius string \| number '' 自定义圆角,优先级高于 shape 预设
color string '' 自定义主色,普通态派生背景/边框,text/link/plain 态派生文字色
textColor string '' 文字颜色,不传跟随 type/plain/text 派生
height string \| number '' 按钮高度,不传按 size 档位
fontSize string \| number '' 文字大小,不传按 size 档位
bold boolean false 文字加粗
textValue string '' 按钮文本(纯文字场景与默认插槽等价)
icon string '' 图标名称(内置图标集,见 xq-icon),loading 时自动隐藏
iconSize string \| number '' 图标大小,不传按按钮尺寸自动匹配
iconColor string '' 图标颜色,不传跟随文字色
iconTop string \| number 0 图标垂直偏移,正数向上
loading boolean false 加载中,不响应点击
loadingText string '' 加载中显示的文案,不传沿用按钮文本
loadingSize string \| number '' 加载图标大小,不传按按钮尺寸自动匹配
disabled boolean false 禁用
block boolean false 块级,占满一行
autoInsertSpace boolean false 两个中文字符间自动插空格(仅对 textValue 生效)
throttleTime number 0 点击节流间隔(毫秒),0 为不节流
debounceTime number 0 防抖延迟(毫秒):停止点击后达到间隔才触发,0 为不防抖
hoverClass string '' 按压态类名,不传用内置按压反馈
hoverStartTime number 20 按住后多久出现按压态(毫秒)
hoverStayTime number 150 手指松开后按压态保留时间(毫秒)
nativeType 'button' \| 'submit' \| 'reset' 'button' 原生 type 语义(参数保留)
formType 'submit' \| 'reset' - 与 nativeType 同义
openType string '' 微信/支付宝小程序开放能力(仅参数保留,见下方注意事项)
Events 说明 回调参数
click 点击按钮时触发(loading / disabled 下不触发) event: UniPointerEvent
Slots 说明
default 按钮文字(纯文本)
content 富内容(图文混排等复杂结构)
icon 左侧图标(优先级低于 icon 属性)

小程序开放能力说明:uni-app x 中组件根节点为 view,微信/支付宝小程序的 open-type(分享、授权、客服等)必须由原生 <button> 承载,组件内无法直接透传。需要开放能力时请用外层 <button open-type="..."> 包裹或自行封装。openType 属性仅作参数保留,便于业务层条件编译分发。

xq-button-group 按钮组

Props 类型 默认值 说明
size 'large' \| 'normal' \| 'small' \| 'mini' 'normal' 统一子按钮尺寸
type 同 xq-button type 'default' 统一子按钮类型
disabled boolean false 统一禁用子按钮

子按钮通过 inject 接收组上下文,相邻按钮自动贴合(非 App 端用相邻选择器实现)。

<xq-button-group>
    <xq-button>上一页</xq-button>
    <xq-button>下一页</xq-button>
</xq-button-group>

xq-badge 徽标

按钮、图标右上角的数字/圆点状态标记。API:无默认插槽时按独立徽标展示(不绝对定位)。

Props 类型 默认值 说明
value string \| number '' 显示的数字或文字,超过 max 显示为 max+
max number 99 最大值,超出显示 max+
dot / isDot boolean false 显示为小圆点(不显示内容),任一生效
show boolean true 是否显示
hidden boolean false 是否隐藏(优先于 show)
showZero boolean true 值为 0 时是否显示
absolute boolean true 贴在内容角上;无默认插槽时自动按独立徽标展示
position 'top-right' \| 'top-left' \| 'bottom-right' \| 'bottom-left' 'top-right' 贴附的角
offset number[] [] 偏移 [top, right](px);未传项用内置基准(凸出角上一半)
isCenter boolean false 徽标中心与所贴角点重合,生效时 offset 失效
type 'default' \| 'primary' \| 'success' \| 'warning' \| 'error' \| 'info' 'error' 颜色类型
size 'normal' \| 'small' \| 'mini' 'normal' 尺寸,mini 整体缩小
fontSize string \| number '' 自定义字号
bgColor string '' 自定义背景色,优先于 type
textColor string '' 自定义文字颜色
badgeClass / badgeStyle string '' 追加到徽标节点的类名 / 内联样式
customClass / customStyle string '' 追加到根节点的类名 / 内联样式

Slots:default(被标记的内容)、content(自定义徽标内容)。

<!-- 默认贴右上角 -->
<xq-badge :value="6"><xq-icon name="shopping_cart" /></xq-badge>
<!-- 左下角 + 中心与角点重合 -->
<xq-badge value="new" position="bottom-left" is-center><xq-button>消息</xq-button></xq-badge>

徽标凸出角外的可见性需要祖先链配合:组件根节点已内置 overflow: visible,但 uni-app x 的 view 默认裁切溢出内容(Web 端来自框架基础样式 uni-app uni-view { overflow: hidden })。若包裹徽标的容器贴得很紧(如 flex 行内直接包裹),请在包裹容器上显式加 overflow: visible,否则凸出部分会被裁掉;容器有内边距且凸出量落在 padding box 内时无需处理。

xq-icon 图标

name 传内置图标名渲染字体图标(共 116 个,字体随库打包,无需额外引入),传图片地址渲染图片;也可用 unicode / 默认插槽注入自定义字体字符。

Props 类型 默认值 说明
name string '' 内置图标名或图片地址(含 / 或以 data: 开头时渲染为图片)
unicode string '' 字体图标的 unicode 字符,优先于 name 的码点表查找
customPrefix string '' 自定义字体图标库的字体族名,覆盖内置字体
fontFamily string '' 字体族名(customPrefix 别名,兼容旧用法)
type 'default' \| 'primary' \| 'success' \| 'warning' \| 'error' \| 'info' 'default' 主题色类型
color string '' 自定义颜色,可传主题色名或色值,优先于 type
size string \| number 'inherit' 字号,inherit 表示跟随父级
bold boolean false 加粗
top string \| number 0 垂直微调
width / height string \| number '' 图片宽高,不传时回退到 size
imgMode string 'widthFix' 图片裁剪模式

Events:click、touchstart。Slots:default(自定义字体图标的 unicode 字符)。

图标名清单:import { iconNames, iconCodes, getIconCode } from '@/uni_modules/xq-ui'。

图标字体由 Material Symbols Rounded(Apache License 2.0)实例化并裁剪为 116 个图标子集,字体文件位于 static/font/xq-icons.ttf,@font-face 注册见 theme/index.scss。

xq-tag 标签

API:六种类型(danger 为 error 别名)、四档尺寸、四种形状,effect 三主题,自定义颜色与禁用。

Props 类型 默认值 说明
text string \| number '' 标签文本(default 插槽可替代)
type 'default' \| 'primary' \| 'success' \| 'warning' \| 'error' \| 'danger' \| 'info' 'primary' 类型色,danger 为 error 别名
size 'large' \| 'normal' \| 'small' \| 'mini' 'normal' 尺寸(高 32 / 24 / 20 / 16px)
shape 'round' \| 'square' \| 'roundLeft' \| 'roundRight' 'round' 形状,roundLeft / roundRight 单侧胶囊
effect 'light' \| 'dark' \| 'plain' 'light' 主题:浅色底 / 实底反白 / 白底描边
plain boolean false 镂空,等价 effect="plain";显式 effect 优先
hairline boolean true 是否描边
closeable boolean false 显示关闭按钮
color string '' 自定义主色作背景与描边,深色底配 textColor
bgColor / borderColor / textColor string '' 自定义背景 / 边框 / 文字色,bgColor 优先于 color
fontSize string \| number '' 文字字号
bold boolean false 文字加粗
borderRadius string \| number '' 自定义圆角,优先于 shape
disabled boolean false 禁用:置灰且不派发 click / close
customClass / customStyle string '' 追加到根节点

Events:click、close(disabled 时不派发;close 带 .stop)。Slots:default。

xq-divider 分割线

Props 类型 默认值 说明
text string '' 分割线文本
contentPosition 'left' \| 'center' \| 'right' 'center' 文本位置
dashed boolean false 虚线
lineColor / textColor string '' 颜色,可传主题色名或色值
textSize string \| number 'inherit' 文本字号

Slots:default。

xq-cell 单元格 / xq-cell-group 单元格分组

xq-cell Props 类型 默认值 说明
title / label / value string '' 标题、描述、右侧内容
icon string '' 左侧图标图片地址
isLink boolean false 显示箭头并响应点击
arrow 'right' \| 'left' \| 'up' \| 'down' 'right' 箭头方向
border boolean true 下边框
center boolean false 垂直居中
required boolean false 必填星号
clickable boolean false 可点击

Events:click。Slots:icon、title、label、value。

xq-cell-group Props:title(分组标题)、border(底部分隔条)。

xq-input 输入框

单行输入框。多行文本请用独立的 xq-textarea,不通过 type="textarea" 切换。

Props 类型 默认值 说明
modelValue string '' 输入内容(v-model)
type 'text' \| 'number' \| 'digit' \| 'tel' \| 'idcard' \| 'email' \| 'url' \| 'nickname' \| 'search' \| 'none' 'text' 键盘类型
password boolean false 密码框(固定密文)
showPassword boolean false 密码框并显示明文 / 密文切换图标
placeholder string '' 占位文字
placeholderClass / placeholderStyle string 'xq-input__placeholder' / '' 占位样式
disabled boolean false 禁用:灰底、文字变淡
readonly boolean false 只读:不可编辑但保持正常外观(原生无 readonly,用 disabled 降级实现)
maxlength number -1 最大长度,-1 不限制
focus boolean false 自动聚焦
confirmType 'send' \| 'search' \| 'next' \| 'go' \| 'done' 'done' 键盘右下角按钮文字
confirmHold / adjustPosition / holdKeyboard boolean false / true / false 透传原生键盘行为
cursorSpacing / cursorColor number / string 0 / '' 光标与键盘距离 / 光标颜色
clearable boolean false 显示清空按钮,有值且可编辑时出现
clearIcon string 'close-circle' 自定义清除图标:内置图标名或图片地址
showWordLimit boolean false 显示字数统计,需同时设 maxlength > 0
wordLimitPosition 'inside' \| 'outside' 'inside' 字数统计位置
formatter / parser ((value: string) => string) \| null null 格式化展示值 / 还原真实值;仅 type 为 text 生效,v-model 始终是真实值
prefix / suffix string '' 左 / 右侧文字
prefixIcon / suffixIcon string '' 左 / 右侧图标
size 'small' \| 'normal' \| 'large' 'normal' 尺寸(高 32 / 40 / 48px)
border 'surround' \| 'bottom' \| 'none' 'surround' 边框样式
align 'left' \| 'center' \| 'right' 'left' 文字对齐
height string \| number '' 输入框高度,不传按 size
iconColor string '' 图标与前后缀文字颜色
inputStyle string '' 输入框内联样式
inputId string '' 输入框 id
customClass / customStyle string '' 追加到根节点

Events:update:modelValue、input(parser 之后的值)、change(失焦 / 回车且值变化时)、focus、blur、confirm、clear、keyboardheightchange。

Slots:prefix、suffix(替代 prefix / suffixIcon)、prepend、append(复合型输入框,边框外贴合)、clearIcon、passwordIcon(作用域 { visible })。

Expose:focus()、blur()、clear()、isFocused。

<xq-input v-model="keyword" prefix-icon="search" clearable placeholder="搜索" />
<!-- 密码显隐 -->
<xq-input v-model="pwd" show-password placeholder="请输入密码" />
<!-- 复合型 -->
<xq-input v-model="url" placeholder="请输入网址">
  <template #prepend><text>Https://</text></template>
  <template #append><text>.com</text></template>
</xq-input>
<!-- 千分位:v-model 拿到真实值 -->
<xq-input v-model="amount" :formatter="thousands" :parser="unThousands" />

readonly 是降级实现:uni-app x 的原生 input 没有 readonly,组件用 disabled 阻止编辑,但不加灰底与文字淡化,视觉上与可编辑状态一致。

xq-textarea 文本域

多行文本输入,是独立于 xq-input 的单独组件。

Props 类型 默认值 说明
modelValue string '' 输入内容(v-model)
placeholder string '' 占位文字
placeholderClass / placeholderStyle string 'xq-textarea__placeholder' / '' 占位样式
height string \| number 80 固定高度;autoHeight / autosize 生效时失效
autosize boolean \| { minRows?: number; maxRows?: number } false 自适应高度:true 随内容增高;对象在行数上下限间自适应,超出 maxRows 内部滚动。优先于 autoHeight
autoHeight boolean false 随内容自动增高,等价 autosize=true
maxlength number -1 最大长度,-1 不限制
count boolean false 右下角显示字数统计
showWordLimit boolean false 显示字数统计,与 count 任一为真即显示
wordLimitPosition 'inside' \| 'outside' 'outside' 字数统计位置:outside 输入框下方另起一行(默认);inside 悬浮在输入框内右下角(不占位、不挡输入)
clearable boolean false 显示清空按钮:位于输入框右上角、滚动条左侧
clearIcon string 'close-circle' 自定义清除图标
disabled boolean false 禁用:灰底、文字变淡
readonly boolean false 只读:不可编辑但保持正常外观(降级实现同 xq-input)
focus boolean false 自动聚焦
confirmType 'return' \| 'send' \| 'search' \| 'next' \| 'go' \| 'done' 'return' 键盘右下角按钮文字(Android 系统限制仅换行)
confirmHold / adjustPosition / holdKeyboard boolean false / true / false 透传原生键盘行为
cursorSpacing / cursorColor number / string 0 / '' 光标与键盘距离 / 光标颜色
showConfirmBar boolean true 是否显示键盘上方「完成」按钮栏(iOS)
disableDefaultPadding boolean false 去掉 iOS 默认内边距
border 'surround' \| 'bottom' \| 'none' 'surround' 边框样式
iconColor string '' 清除图标颜色
inputId string '' 输入框 id
customClass / customStyle string '' 追加到根节点

Events:update:modelValue、input、change(失焦 / 回车且值变化时)、focus、blur、confirm、linechange、clear、keyboardheightchange。

Slots:clearIcon。Expose:focus()、blur()、clear()、isFocused。

<xq-textarea v-model="remark" :maxlength="200" show-word-limit placeholder="请输入备注" />
<!-- 2 ~ 4 行自适应 -->
<xq-textarea v-model="bio" :autosize="{ minRows: 2, maxRows: 4 }" clearable />

maxRows 的实现方式:设置 maxRows 时会关闭原生 auto-height,改由 @linechange 上报的内容高度驱动一个受控高度, 夹在 minRows × 21px 与 maxRows × 21px 之间。这是因为原生 auto-height 在 Web 端会把内部 textarea 的 overflow-y 强制为 hidden,配合 max-height 只会裁切内容而不会滚动。

行高按 14px 字号 × 1.5 估算(每行 21px)。若通过 customStyle 改了字号,请改用 height 固定高度。

xq-rate 评分

星级评分,

Props 类型 默认值 说明
modelValue number 0 当前分值(v-model);传负数表示不使用双向绑定,回退到 current
current number 0 未使用 v-model 时的初始分值
max / count number \| string 0 / 5 星星总数,max 大于 0 时优先
size 'small' \| 'normal' \| 'large' \| number 'normal' 星星尺寸:预设 14 / 18 / 24px,或传具体数值
gutter number \| string 5 星星之间的间距
disabled boolean false 只读展示,不响应点击,未选中色可单独配置
allowHalf boolean false 允许半选
lowThreshold / highThreshold number 2 / 4 分段界限值:<= low 取第一段,>= high 取第三段,其余第二段
colors string[] null 分段选中色:长度 3 按阈值分段;长度等于星数时逐颗取色;其它长度取首项
activeColor / voidColor string '' 选中色(默认主题 warning)/ 未选中色(默认 #c6d1de)
inactiveColor / disabledVoidColor string '' voidColor 的别名 / 禁用时的未选中色
icons string[] null 分段选中图标,分段规则同 colors
activeIcon / voidIcon string '' 选中 / 未选中图标名(默认 star),也支持图片地址
inactiveIcon / disabledVoidIcon string '' voidIcon 的别名 / 禁用时的未选中图标
customPrefix string '' 自定义图标字体的字体族名
showText boolean false 显示辅助文字
texts string[] [] 辅助文字数组,下标对应分值
showScore boolean false 显示当前分值
scoreTemplate string '{value}' 分值模板,{value} 替换为当前分值
textColor string '' 辅助文字颜色
clearable boolean false 再次点击相同分值清零
minCount number \| string 0 最少选中的星数,低于该值不生效
customClass / customStyle string '' 追加到根节点

Events:update:modelValue、change(点击或触摸松手后触发,参数为当前分值)。

Expose:setCurrentValue(value)(仅改组件内分值,不派发事件)、resetCurrentValue()。

<xq-rate v-model="score" show-score />
<!-- 半选 + 辅助文字 -->
<xq-rate v-model="score" allow-half show-text :texts="['极差', '失望', '一般', '满意', '惊喜']" />
<!-- 分段颜色:低 / 中 / 高 -->
<xq-rate v-model="score" :colors="['#909399', '#ff9f1a', '#18b668']" />
<!-- 换成心形图标 -->
<xq-rate v-model="score" void-icon="heart" />

评分支持点击与触摸拖动两种交互:拖动过程中只更新分值,松手后才派发一次 change。

内置图标字体只有一个描边 star,没有实心星。选中与未选中靠颜色区分;需要实心星时,用 customPrefix 指定自定义图标字体并传入对应图标名,或给 voidIcon / activeIcon 传图片地址。

半颗星通过「底层未选中图标 + 覆盖层裁剪填充」实现,不依赖额外的实心图标资源。

xq-input-otp 一次性密码输入框

内部由一个隐藏的原生 input 承接输入(键盘、删除、粘贴全部走原生行为),格子只是值与光标的展示层。

Props 类型 默认值 说明
modelValue string \| number '' 当前值(v-model),组件输出字符串
length number 6 输入位数
validator (value: string) => boolean null 单字符校验,返回 false 的字符不进入值
inputmode 'text' \| 'numeric' \| 'decimal' \| 'tel' 'numeric' 键盘类型,映射 uni input 的 type(numeric → number、decimal → digit)
type 'outlined' \| 'filled' \| 'underlined' 'outlined' 外观类型
size 'large' \| 'default' \| 'small' 'default' 尺寸,格子 44 / 36 / 32px
mask boolean false 密码模式,显示为圆点
disabled boolean false 禁用:置灰且不可交互
readonly boolean false 只读:保持外观不可输入(降级实现同 xq-input)
separator string '' 相邻格子之间的分隔符,空串不渲染
customClass / customStyle string '' 追加到根节点

Events:update:modelValue、change(失焦且值变化时触发)、finish(填满时触发)、focus、blur。

Expose:focus()、blur()、isFocused。

<xq-input-otp v-model="code" @finish="submit" />
<!-- 4 位纯字母,全键盘 -->
<xq-input-otp v-model="code" :length="4" :validator="onlyLetter" inputmode="text" />
<!-- 填充外观 + 密码模式 + 分隔符 -->
<xq-input-otp v-model="code" type="filled" mask separator="-" />

separator 在 uni-app x 下降级为字符串 prop;validate-event / id / aria-label 未纳入。 聚焦方式:点击格子区域,或通过 ref 调用 focus()。

主题变量

主题变量全部以 --xq- 开头,源码为 theme/index.scss(亮/暗 token 各放一个 SCSS map,mixin 展开生成声明),编译产物定义在 page 选择器下,暗黑值写在 prefers-color-scheme 媒体查询里。

变量组 示例
类型色 --xq-color-primary、-dark、-disabled、-light(success / warning / error / info 同构)
字体色 --xq-text-color、--xq-text-color-content、--xq-text-color-tips、--xq-text-color-light
边框与分隔 --xq-border-color、--xq-divider-color
背景 --xq-bg-color、--xq-bg-color-white、--xq-bg-color-gray-light
字号 --xq-font-size-xs ~ --xq-font-size-xl
圆角 --xq-border-radius-sm / -base / -lg / -round
间距 --xq-spacing-xs ~ --xq-spacing-xl

注意:

  1. App 端不支持 :root,不要把变量写到 :root 下。
  2. 变量值里不能再套 var(),需要换色时直接覆盖具体色值。
  3. 原生导航栏、tabBar、页面背景色不受这些变量控制,需要项目提供 theme.json。

已知限制

  • xq-button 加载态为 view + 单边 border 圆环旋转动画(蒸汽模式无 CSS animation 部分属性,实测可用);纯图标按钮对图标字体做 0.09em 垂直补偿(更换图标字体后可调 ICON_VERTICAL_OFFSET_EM)。
  • xq-toast / xq-modal 均已实现:函数式 useToast / useModal + 页面挂载 <xq-toast global /> / <xq-modal global /> 承接实例,未挂载时回退官方 API。
  • 自定义主题色(运行时换色)依赖 CSS 变量下发;App 端主题切换经 xq-config-provider 承载。
  • 已完成 Web + Android 蒸汽模式编译验证(0 CSS 警告);iOS / HarmonyOS / 微信 / 支付宝等小程序编译与真机验证待环境接入。

隐私、权限声明

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

无

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

插件不采集任何数据

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

无

许可协议

MIT协议

暂无用户评论。