v-umeditor

0.4.7 • Public • Published

v-umeditor

UMeditor(ueditor的mini版) 1.2.3 的Vue版本。 加入自定义UI,适应现代风格

完整DEMO

代码DEMO

安装

npm i v-umeditor -S

yarn add v-umeditor

全局引用

import vUeditor from 'v-umeditor'
 
Vue.use(vUeditor)

在组件内引用

import { vUeditor } from 'v-umeditor'
 
components: {
  vUeditor
}

使用

<v-ueditor
  :config="config"
  @ready="ueditorReady"
></v-ueditor>

注: 开启vue keep-alive时,当使用ready参数保存返回的编辑器实例,当第二次进入页面时,通过返回实例获取内容报错。建议使用window.UM.getEditor(id)方式获取实例

props

字段 必填 类型 默认值 描述
id String 当前编辑器 id
content String 初始化数据内容
config Object {} 配置参数,详细参考 https://github.com/JakeLaoyu/v-umeditor/blob/master/static/umeditor.config.js
newstyle Boolean true 是否使用新样式
useCustomUpload Boolean false 是否使用 自定义文件上传

Events

字段 描述 return
ready UEditor初始化后返回UEditor实例对象,可以调用实例方法,文档: http://ueditor.baidu.com/doc/#UE.Editor UE实例
change 监听UEditor内容改变,返回UEditor实例对象,可以调用实例方法,文档: http://ueditor.baidu.com/doc/#UE.Editor UE实例

注: 目前发现contentchange事件在选中删除时不触发,建议同时监听contentchangeselectionchange事件,使用window.UM.getEditor(id).getContent()获取内容

或者

// 获取实例
window.UM.getEditor(id)

图片上传

官方配置

请参考官方DEMO文档,需要后端配合 https://ueditor.baidu.com/website/download.html#mini

ajax异步上传

需要开启useCustomUpload配置

使用formDate格式上传,服务端返回格式:

{
  message: 'SUCCESS',
  url: 'xxx'
}

Readme

Keywords

none

Package Sidebar

Install

npm i v-umeditor

Weekly Downloads

20

Version

0.4.7

License

MIT

Unpacked Size

2.51 MB

Total Files

4

Last publish

Collaborators

  • jakelaoyu