react中引入ueditor
1.放入静态资源并配置
首先把官网下载的Ueditor资源,放入public文件夹中。(你的U盘里有,不用下载了)
2.封装一个组件 UEditor.js ,放到src/pages/components/里
/**
* @module 百度富文本编辑器
* 自定义菜单配置
*/
import React, { Component } from 'react'
let editor = null
class UEditor extends Component {
componentDidMount () {
this.setConfig()
}
componentWillUnmount () {
editor.destroy()
}
// 初始化编辑器
setConfig () {
editor = window.UE.getEditor('editor', {
toolbars: [
[
'source', // 源代码
// 'anchor', // 锚点
'undo', // 撤销
'redo', // 重做
'bold', // 加粗
'indent', // 首行缩进
// 'snapscreen', // 截图
'italic', // 斜体
'underline', // 下划线
'strikethrough', // 删除线
'sub