2019-05-17 12:05:03 +08:00
|
|
|
---
|
|
|
|
category: Components
|
|
|
|
subtitle: 提及
|
|
|
|
type: 数据录入
|
|
|
|
title: Mentions
|
2020-06-05 13:50:09 +08:00
|
|
|
cover: https://gw.alipayobjects.com/zos/alicdn/jPE-itMFM/Mentions.svg
|
2019-05-17 12:05:03 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
提及组件。
|
|
|
|
|
|
|
|
## 何时使用
|
|
|
|
|
|
|
|
用于在输入中提及某人或某事,常用于发布、聊天或评论功能。
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
<Mentions onChange={onChange}>
|
|
|
|
<Mentions.Option value="sample">Sample</Mentions.Option>
|
|
|
|
</Mentions>
|
|
|
|
```
|
|
|
|
|
2019-09-02 15:25:11 +08:00
|
|
|
### Mentions
|
2019-05-17 12:05:03 +08:00
|
|
|
|
2019-11-22 14:37:39 +08:00
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|
|
| --- | --- | --- | --- |
|
2020-06-17 23:18:14 +08:00
|
|
|
| autoFocus | 自动获得焦点 | boolean | false |
|
2020-10-21 10:33:43 +08:00
|
|
|
| autoSize | 自适应内容高度,可设置为 true \| false 或对象:{ minRows: 2, maxRows: 6 } | boolean \| object | false |
|
2020-07-01 15:14:31 +08:00
|
|
|
| defaultValue | 默认值 | string | - |
|
|
|
|
| filterOption | 自定义过滤逻辑 | false \| (input: string, option: OptionProps) => boolean | - |
|
2020-10-21 10:33:43 +08:00
|
|
|
| getPopupContainer | 指定建议框挂载的 HTML 节点 | () => HTMLElement | - |
|
2020-07-01 15:14:31 +08:00
|
|
|
| notFoundContent | 当下拉列表为空时显示的内容 | ReactNode | `Not Found` |
|
2020-01-17 17:23:48 +08:00
|
|
|
| placement | 弹出层展示位置 | `top` \| `bottom` | `bottom` |
|
2020-10-21 10:33:43 +08:00
|
|
|
| prefix | 设置触发关键字 | string \| string\[] | `@` |
|
|
|
|
| split | 设置选中项前后分隔符 | string | ` ` |
|
2020-07-01 15:14:31 +08:00
|
|
|
| validateSearch | 自定义触发验证逻辑 | (text: string, props: MentionsProps) => void | - |
|
|
|
|
| value | 设置值 | string | - |
|
2020-10-21 10:33:43 +08:00
|
|
|
| onBlur | 失去焦点时触发 | () => void | - |
|
2020-07-01 15:14:31 +08:00
|
|
|
| onChange | 值改变时触发 | (text: string) => void | - |
|
|
|
|
| onFocus | 获得焦点时触发 | () => void | - |
|
|
|
|
| onResize | resize 回调 | function({ width, height }) | - |
|
2020-10-21 10:33:43 +08:00
|
|
|
| onSearch | 搜索时触发 | (text: string, prefix: string) => void | - |
|
|
|
|
| onSelect | 选择选项时触发 | (option: OptionProps, prefix: string) => void | - |
|
2019-05-17 12:05:03 +08:00
|
|
|
|
2019-09-02 15:25:11 +08:00
|
|
|
### Mentions 方法
|
2019-05-17 12:05:03 +08:00
|
|
|
|
2020-12-24 12:02:57 +08:00
|
|
|
| 名称 | 描述 |
|
|
|
|
| ------- | -------- |
|
|
|
|
| blur() | 移除焦点 |
|
2019-11-22 14:37:39 +08:00
|
|
|
| focus() | 获取焦点 |
|
2019-05-17 12:05:03 +08:00
|
|
|
|
|
|
|
### Option
|
|
|
|
|
2020-12-24 12:02:57 +08:00
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|
|
| -------- | -------------- | --------- | ------ |
|
|
|
|
| children | 选项内容 | ReactNode | - |
|
|
|
|
| value | 选择时填充的值 | string | - |
|