Skip to content

Switch ​

Vue 已实现 · 还原验收 0/1 · 上游演示 · 固定版本源码

预览 ​

用法 ​

vue
<script setup lang="ts">
import { Switch } from 'beui-vue'
import { shallowRef } from 'vue'

const on = shallowRef(true)
const off = shallowRef(false)
</script>

<template>
  <div class="switch-demo">
    <Switch v-model:checked="on" label="Enable notifications" />
    <Switch v-model:checked="off" label="Off" />
    <Switch checked disabled label="Disabled" />
  </div>
</template>

<style scoped>
.switch-demo { display: flex; flex-direction: column; gap: .75rem; }
</style>

API ​

v-model:checked 双向绑定,也可用 :checked 与 @checked-change。disabled 禁用交互,label 显示关联标签,ariaLabel 为无外部标签的开关命名。

还原验收 ​

基于 beUI 的独立 Vue 移植,依 MIT 许可证分发。