1.Simditor组件的github地址:https://github.com/mycolorway/simditor 网址:http://simditor.tower.im/

2.在util里边新建rich-editor文件夹,里边新建index.jsx

  1. import React from 'react';
  2. import Simditor from 'simditor';
  3. import 'simditor/styles/simditor.scss';
  4. import './index.scss';
  5. // 通用的富文本编辑器,依赖jquery
  6. class RichEditor extends React.Component{
  7.     constructor(props){
  8.         super(props);
  9.     }
  10.     componentDidMount(){
  11.         this.loadEditor();
  12.     }
  13.  
  14.     loadEditor(){
  15.           let element=this.refs["textarea"];
  16.           this.simditor=new Simditor({
  17.               textarea: $(element),
  18.               defaultValue: this.props.placeholder || "请输入内容",
  19.               upload: {
  20.                 url : '/manage/product/richtext_img_upload.do',
  21.                 defaultImage : '',
  22.                 fileKey : 'upload_file'
  23.             }
  24.           });
  25.           //上传数据
  26.           this.bindEditorEvent();
  27.     }
  28.     //初始化富文本编辑器的事件
  29.     bindEditorEvent(){
  30.        this.simditor.on("valuechanged", e => {
  31.            this.props.onValueChange(this.simditor.getValue())
  32.        })
  33.     }
  34.     render(){
  35.         return (
  36.            <div className="rich-editor">
  37.                <textarea ref="textarea"></textarea>
  38.            </div>
  39.         );
  40.     }
  41. }
  42.  
  43. export default RichEditor;

3.在save.jsx里边使用RichEditor组件

  1. import RichEditor from 'util/rich-editor/index.jsx'
  2. <div className="form-group">
  3.                         <label className="col-md-2 control-label">商品详情</label>
  4.                         <div className="col-md-10">
  5.                            <RichEditor onValueChange={(value) => {this.onDetailValueChange(value)}}/>
  6.                         </div>
  7.                     </div>

4.在RichEditor里边定义valuechanged事件,监听文本编辑器里边内容的变化,当内容变化时触发 valuechange事件,调用onDetailValueChange函数,传入新的内容,更新state里边detail的值

  1. //富文本编辑器
  2.   onDetailValueChange(value){
  3.       this.setState({
  4.           detail : value
  5.       })
  6.   }

React后台管理系统-rich-editor组件的更多相关文章

  1. React后台管理系统-添加商品组件

    引入了CategorySelector 二级联动组件.FileUploader图片上传组件和RichEditor富文本编辑组件 import React from 'react'; import MU ...

  2. React后台管理系统- rc-pagination分页组件封装

    1.用户列表页面使用的rc-pagination分页组件 Github地址: https://github.com/react-component/pagination 2.安装 cnpm insta ...

  3. React后台管理系统-首页Home组件

    1.Home组件要显示用户总数.商品总数和订单总数,数据请求后端的 /manage/statistic/base_count.do接口,返回的是 this.state = {            u ...

  4. 《React后台管理系统实战 :一》:目录结构、引入antd、引入路由、写login页面、使用antd的form登录组件、form前台验证、高阶函数/组件

    实战 上接,笔记:https://blog.csdn.net/u010132177/article/details/104150177 https://gitee.com/pasaulis/react ...

  5. 【共享单车】—— React后台管理系统开发手记:主页面架构设计

    前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...

  6. react后台管理系统路由方案及react-router原理解析

        最近做了一个后台管理系统主体框架是基于React进行开发的,因此系统的路由管理,选用了react-router(4.3.1)插件进行路由页面的管理配置. 实现原理剖析 1.hash的方式   ...

  7. 《React后台管理系统实战 :三》header组件:页面排版、天气请求接口及页面调用、时间格式化及使用定时器、退出函数

    一.布局及排版 1.布局src/pages/admin/header/index.jsx import React,{Component} from 'react' import './header. ...

  8. 《React后台管理系统实战 :二》antd左导航:cmd批量创建子/目录、用antd进行页面布局、分离左导航为单独组件、子路由、动态写左导航、css样式相对陷阱

    一.admin页面布局及路由创建 0)cmd批量创建目录及子目录 //创建各个目录,及charts和子目录bar md home category product role user charts\b ...

  9. 【共享单车】—— React后台管理系统开发手记:UI菜单各个组件使用(Andt UI组件)

    前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...

  10. 【共享单车】—— React后台管理系统开发手记:AntD Form基础组件

    前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...

随机推荐

  1. Codeforces Round #364 (Div. 2) B

    Description Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is e ...

  2. Telerik RadPropertyGrid 设置显隐 Combox选择

    Telerik RadPropertyGrid 的排序按钮.搜索框和描述面板的显隐只要设置SortAndGroupButtons.SearchBox.DescriptionPanel的属性值改为Vis ...

  3. 016 3Sum Closest 最接近的三数之和

    Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...

  4. linux下各种格式软件的安装(引用http://blog.csdn.net/zyz511919766/article/details/7574040)

    首先介绍两个简单的方式 第一:sudo apt-get install packagename 命令 如果我们知道我们要安装的软件的确切的名称,那么我们可以简单的通过此条命令来获取和安装软件.apt- ...

  5. Unity 碰撞的条件

  6. (转)CentOS系统启动流程图文详解

    CentOS系统启动流程图文详解. 原文:http://www.linuxidc.com/Linux/2017-03/141966.htm 熟悉系统启动流程对于我们学习Linux系统是非常有帮助的,虽 ...

  7. HDU 5505——GT and numbers——————【素数】

    GT and numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  8. gitk更改主题设置打不开

    ➜ project git:(master) gitk Error in startup script: unknown color name "lime" (processing ...

  9. 在Magento System Configuration页面添加配置项

    以 Jp_Coupon 模块为例: 目标: 在 System configuration 页面添加一个 JP tab, 在JP中添加 Coupon section, 然后给 Coupon sectio ...

  10. vs移动团队项目集合

    vs移动团队项目集合: https://msdn.microsoft.com/zh-cn/library/vs/alm/dd936138(v=vs.120)/css