[javascript] vue項目cdn模式下使用wangEditor

在GOFLY項目的實現過程中,需要使用富文本編輯器,現在使用下wangEditor

 

很簡單,先引入

<script src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script>

 

再使用

html中

<div id="welcomeEditor"></div>

 

在methods方法中加入

            initEditor(){
                if(this.editor!=null){
                    return;
                }
                const E = window.wangEditor
                this.editor = new E('#welcomeEditor')
                this.editor.config.height = 240;
                this.editor.config.menus = [
                    'head',
                    'bold',
                    'fontSize',
                    'fontName',
                    'italic',
                    'underline',
                    'strikeThrough',
                    'indent',
                    'lineHeight',
                    'foreColor',
                    'backColor',
                    'link',
                    'justify',
                    'emoticon',
                    'table',
                    'splitLine',
                    'undo',
                    'redo',
                ]
                this.editor.create();
            }
        },

獲取html內容

this.editor.txt.html();

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章