1.html
<div id="div1"></div>
2.js
<script src="/static/js/wangEditor.min.js"></script>
<script type="text/javascript">
const E = window.wangEditor;
const editor = new E("#div1");
// 或者 const editor = new E(document.getElementById('div1'))
// 设置默认的提示内容
editor.config.placeholder = '';
//可使用base64格式保存图片 可以选择本地图片 编辑器用base64格式来显示图片 与uploadImgServer (上传图片到服务器)不能同时使用
editor.config.uploadImgShowBase64 = true;
// 忽略粘贴的图片
editor.config.pasteIgnoreImg = true;
//隐藏插入网络图片的功能
editor.config.showLinkImg = false;
//关闭粘贴样式的过滤
//editor.config.pasteFilterStyle = false;
// 配置菜单栏,设置不需要的菜单
editor.config.excludeMenus = [
'emoticon', //表情
'video' // 视频功能
]
editor.create()
</script>
可以用 editor.txt.html()
获取 html内容 这里获取到的是 html代码 这一块是没有样式的 需引入样式 样式可参考官网
可以用 editor.txt.text()
获取 text内容 这里获取到的是文字内容