[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();

开源作品

GOFLY是一款基于Golang+Vue开发的在线客服系统,软件著作权编号:2021SR1462600。一套可私有化部署的在线客服系统,编译后的二进制文件可直接使用无需搭开发环境,下载zip解压即可,仅依赖MySQL数据库,是一个开箱即用的网页在线客服系统,致力于帮助广大开发者/中小站长快速整合私有客服功能。
github地址:go-fly
官网地址:https://gofly.sopans.com
原文地址:https://www.cnblogs.com/taoshihan/p/15808575.html