最近使用wangEditor作为富文本编辑器开发,上传图片时遇到了一些麻烦,废话不多说,直接上代码

<div id="div1" style="left:15%;width:70%;position:absolute;">
    <p>欢迎使用 wangEditor 编辑器</p>
</div>
<button id="btn1">获取html</button>
<button id="btn2">获取text</button>
<script type="text/javascript" src="/wangEditor.min.js"></script>
<script type="text/javascript">
    var E = window.wangEditor
    var editor = new E('#div1')
    editor.customConfig.debug=true;
    editor.customConfig.uploadImgServer = '/upload'
    editor.customConfig.uploadFileName = 'myFileName';
    editor.customConfig.debug = true
    editor.create()
    
        document.getElementById('btn1').addEventListener('click', function () {
        // 读取 html
        alert(editor.txt.html())
        console.log(editor.txt.html())
    }, false)
    document.getElementById('btn2').addEventListener('click', function () {
        // 读取 text
        alert(editor.txt.text())
    }, false)
    console.log(22)
</script>

  

猜你喜欢

转载自www.cnblogs.com/imggr/p/8949500.html
今日推荐