富文本采用wangEditor
创建
主界面
1 | // app.js |
配置文件
1 | // wangEditorSettings.js |
界面显示带标签内容
主要是采用React提供的dangerouslySetInnerHTML。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20// view.js
class View extends Component {
constructor(props) {
super(props);
//...
}
//...
render() {
const { description } = this.state;
return(
<div
className={styles['description']}
dangerouslySetInnerHTML={{__html: description && description.replace(/<script>/, '<script>').replace(/<\/script>/, '<script>')}}
>
</div>
);
}
}