react-app中引入UEditor富文本编辑器

本文介绍了如何在React应用中集成UEditor富文本编辑器,包括将资源放入public目录,封装UEditor组件以及在index.html中引入编辑器,并在需要的地方使用组件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值