---
name: jjb-cloud-component-selectors
description: 定义 JJB 常用选择器云组件使用规范。在使用人员选择器等选择器云组件时查阅。
---
# 云组件使用规范
## 常用选择器云组件
## 人员选择器云组件
人员选择器云组件用于选择人员信息,支持多选功能。
### 组件地址
```
https://cdn.cqjjb.cn/jcloud/use/plugin/8affaf90794911eebf4ca14dc4217ddd/latest
```
### 组件属性
| 属性 | 类型 | 必需 | 默认值 | 描述 |
|------|------|------|--------|------|
| `value` | `Array<{ id: string, name: string }>` | ❌ | `[]` | 已选中的数据 |
| `onOk` | `(data: Array<{ id: string, name: string }>) => void` | ❌ | - | 确认回调,返回选中的数据 |
| `onCancel` | `() => void` | ❌ | - | 取消回调 |
### 类型定义
```typescript
// 人员数据类型
interface Person {
id: string;
name: string;
}
// 组件属性类型
interface PersonSelectorProps {
value?: Person[];
onOk?: (data: Person[]) => void;
onCancel?: () => void;
}
```
### 基础用法
```javascript
import React, { useState } from 'react';
import CloudComponent from '@cqsjjb/jjb-cloud-component/CloudComponent';
function MyPage() {
const [selectedPersons, setSelectedPersons] = useState([
{ id: '1', name: '张三' },
{ id: '2', name: '李四' }
]);
const handleOk = (data) => {
setSelectedPersons(data);
console.log('已选择人员:', data);
};
const handleCancel = () => {
console.log('取消选择');
};
return (
已选择人员: