1.安装react-draft-wysiwyg
cnpm i react-draft-wysiwyg
2.安装draftjs-to-html
cnpm i draftjs-to-html
3.安装html-to-draftjs
cnpm i html-to-draftjs
代码:
import React, {
useState, useEffect } from 'react'
import {
Editor } from "react-draft-wysiwyg";
import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
import draftToHtml from 'draftjs-to-html'
import htmlToDraft from 'html-to-draftjs'
import {
EditorState, convertToRaw, ContentState