最近在vue项目中需要使用富文本编辑器,于是将Ueditor集成进来,作为公共组件。
项目地址:https://github.com/suweiteng/vue2-management-platform
1.放入静态资源并配置
首先把官网下载的Ueditor资源,放入静态资源src/static中。
修改ueditor.config.js中的window.UEDITOR_HOME_URL配置,如下图:
2.引入
在main.js中引入
rush:js;">
import '../static/UE/ueditor.config.js'
import '../static/UE/ueditor.all.min.js'
import '../static/UE/lang/zh-cn/zh-cn.js'
import '../static/UE/ueditor.parse.min.js'
3.开发公共组件
开发公共组件,可设置填充内容defaultMsg,配置信息config(宽度和高度等),并提供获取内容的方法。
效果如下: