wangEditor官网地址:https://www.wangeditor.com/
在react中有两种方式:
这里推荐第一种->自己动手开发,因为第二种使用现成的插件里边封装了很多,里边的方法非常多也很复杂,同时也给你扩展了很多东西,感觉对于新手来说上手难度较大,所以建议直接自己动手开发。
基本使用
先下载
npm 安装 npm i wangeditor --save
两种使用方法:
使用 js 外链引入
<div id="div1">
<p>欢迎使用 <b>wangEditor</b> 富文本编辑器</p>
</div>
<!-- 引入 wangEditor.min.js -->
<script type="text/javascript">
const E = window.wangEditor
const editor = new E('#div1')
// 或者 const editor = new E( document.getElementById('div1') )
editor.create()
</script>
使用 npm 安装
import E from 'wangeditor'
const editor = new E('#div1')
// 或者 const editor = new E( document.getElementById('div1') )
editor.create()