2016-07-04 10:31:27 +08:00
|
|
|
---
|
|
|
|
category: Components
|
2016-09-21 11:28:38 +08:00
|
|
|
subtitle: 提及
|
2016-07-04 10:31:27 +08:00
|
|
|
cols: 1
|
|
|
|
type: Views
|
2016-09-21 11:28:38 +08:00
|
|
|
title: Mention
|
2016-07-04 10:31:27 +08:00
|
|
|
---
|
|
|
|
|
2016-07-21 15:23:04 +08:00
|
|
|
提及组件。
|
2016-07-04 10:31:27 +08:00
|
|
|
|
|
|
|
## 何时使用
|
|
|
|
|
2016-07-21 15:41:40 +08:00
|
|
|
用于在输入中提及某人或某事,常用于发布、聊天或评论功能。
|
|
|
|
|
|
|
|
## API
|
2016-07-04 10:31:27 +08:00
|
|
|
|
2016-07-21 15:23:04 +08:00
|
|
|
```jsx
|
|
|
|
<Mention
|
|
|
|
onChange={onChange}
|
|
|
|
suggestions={['afc163', 'benjycui', 'yiminghe', 'jljsj33', 'dqaria', 'RaoHai']}
|
|
|
|
/>
|
2016-07-04 10:31:27 +08:00
|
|
|
```
|
|
|
|
|
2016-07-20 18:56:44 +08:00
|
|
|
### Mention API
|
|
|
|
|
2016-07-21 15:23:04 +08:00
|
|
|
| API | 说明 | 类型 |
|
2016-07-20 18:56:44 +08:00
|
|
|
|----------|---------------|----------|
|
|
|
|
| toString | 把 EditorState 转成字符串 | Function(editorState: EditorState): String |
|
|
|
|
| toEditorState | 把字符串转成 EditorState | Function(string: String): EditorState |
|
|
|
|
| getMentions | 获取当前 editorState 中提到的人的列表 | Function(editorState: EditorState): Array<String> |
|
|
|
|
|
2016-07-04 10:31:27 +08:00
|
|
|
### Mention props
|
|
|
|
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|
|
|----------|---------------|----------|--------------|
|
|
|
|
| suggestions | 建议内容 | Array<string> or Array<Mention.Nav> | [] |
|
2016-08-29 14:46:31 +08:00
|
|
|
| suggestionStyle | 弹出下拉框样式 | Object | {} |
|
2016-07-04 10:31:27 +08:00
|
|
|
| onSearchChange | 输入框中 @ 变化时回调 | function(value:String) | [] |
|
2016-07-19 13:39:05 +08:00
|
|
|
| onChange | 输入框内容变化时回调 | function(editorState: EditorState) | null |
|
2016-09-30 11:26:27 +08:00
|
|
|
| onSelect | 下拉框选择建议时回调 | function(suggestion: String) | null |
|
2016-07-04 10:31:27 +08:00
|
|
|
| notFoundContent| 未找到时的内容 | string | '无匹配结果,轻敲空格完成输入' |
|
|
|
|
| loading | 加载中 | boolean | false |
|
|
|
|
| multiLines | 多行模式 | boolean | false |
|
2016-09-28 16:55:14 +08:00
|
|
|
| prefix | 触发弹出下拉框的字符 | string | '@' |
|
2016-09-30 11:26:27 +08:00
|
|
|
| placeHolder | 输入框默认文字 | string | null |
|
2016-07-19 13:39:05 +08:00
|
|
|
| defaultValue | 默认值 | EditorState, 可以用 Mention.toEditorState(text) 把文字转换成 EditorState | null |
|
2016-07-18 16:58:08 +08:00
|
|
|
| value | 值 | EditorState | null |
|
2016-07-04 10:31:27 +08:00
|
|
|
|
|
|
|
### Nav props
|
|
|
|
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|
|
|----------|---------------|----------|--------------|
|
|
|
|
| value | 建议值,选择建议时,用此值插入到输入框中 | string | "" |
|
|
|
|
| children | 建议内容 | Objet | {} |
|