Checkbox 复选框
本期保持 PrimeVue 4.5.5 原生 API。使用前按快速开始安装插件与 CSS。
交互示例
使用代码
vue
<script setup lang="ts">
import { ref } from 'vue'
import { WCheckbox } from '@wizdomt/ui'
const checked = ref(true)
</script>
<template>
<label><WCheckbox v-model="checked" binary /> 接收通知</label>
<span>{{ checked ? '已开启' : '已关闭' }}</span>
</template>常用 Props / 配置
| 名称 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| modelValue | boolean 或数组值 | 上游支持类型 | undefined |
| binary | 布尔模式 | boolean | false |
| inputId | 关联 label 的 input ID | string | undefined |
事件与方法
update:modelValue、change 保持原生语义。
插槽
icon。
响应式与无障碍
组件保持原生行为,不自动切换交互。为交互元素提供 label 或 aria-label;浮层按容器设置 max-width。响应式指南说明设备验证方法。
完整 Props、事件、Slots、Methods 以上游锁定版本类型声明为准。PrimeVue v4 checkbox 文档可能包含较新 4.x API,使用时以本包 TypeScript 提示为准。