# VSwitch 组件 API 文档

## 组件简介 | Component Introduction
`VSwitch` 是基于 Element Plus 的开关组件，支持多种数据类型和自定义插槽。

`VSwitch` is a switch component based on Element Plus, supporting multiple data types and custom slots.

---

## Props/属性
| 属性名 | 说明 | 类型 | 是否必填 | 默认值 |
|--------|------|------|----------|--------|
| field  | 开关配置对象，详见下表 | Object | 是 | - |

---

## v-model
- 绑定值类型：`Boolean | String | Number`
- 用法：`v-model="switchValue"`

---

## 插槽 | Slots
| 插槽名 | 说明 |
|--------|------|
| active-action | 激活时的自定义内容 |
| inactive-action | 未激活时的自定义内容 |

---

## 方法 | Methods (通过 ref 调用)
| 方法名 | 说明 |
|--------|------|
| focus() | 使开关聚焦 |

---

## 示例 | Example
```vue
<template>
  <VSwitch v-model="switchValue" :field="fieldConfig" ref="switchRef">
    <template #active-action>
      <span>开</span>
    </template>
    <template #inactive-action>
      <span>关</span>
    </template>
  </VSwitch>
</template>

<script setup>
import { ref } from 'vue'
import { VSwitch } from 'your-lib-path'

const switchValue = ref(false)
const switchRef = ref(null)
const fieldConfig = {
  activeText: '开',
  inactiveText: '关'
}
</script>
``` 