UMeditor(ueditor��mini��)��Vue�汾
npm install v-umeditor-psjy> UMeditor(ueditor的mini版) 1.2.3 的Vue版本。
> 加入自定义UI,适应现代风格
``sh`
npm i v-umeditor -S`
或sh`
yarn add v-umeditor
`js
import vUeditor from 'v-umeditor'
Vue.use(vUeditor)
`
`js
import vUeditor from 'v-ueditor'
components: {
vUeditor
}
`
`vue`
@ready="ueditorReady"
>
注: 开启vue keep-alive时,当使用ready参数保存返回的编辑器实例,当第二次进入页面时,通过返回实例获取内容报错。建议使用window.UM.getEditor(id)方式获取实例
| 字段 | 必填 | 类型 | 默认值 | 描述 |
|:-------- |:---- |:------- |:------ |:------------------------------------------------------------------------------------------------ |
| 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 | 是否使用 自定义文件上传 |
| 字段 | 描述 | return |
|:------ |:---------------------------------------------------------------------------------------------------------- |:------ |
| ready | UEditor初始化后返回UEditor实例对象,可以调用实例方法,文档: http://ueditor.baidu.com/doc/#UE.Editor | UE实例 |
| change | 监听UEditor内容改变,返回UEditor实例对象,可以调用实例方法,文档: http://ueditor.baidu.com/doc/#UE.Editor | UE实例 |
注: 目前发现contentchange事件在选中删除时不触发,建议同时监听contentchange和selectionchange事件,使用window.UM.getEditor(id).getContent()获取内容
或者
`js`
// 获取实例
window.UM.getEditor(id)
请参考官方DEMO文档,需要后端配合 https://ueditor.baidu.com/website/download.html#mini
需要开启useCustomUpload配置
使用formDate格式上传,服务端返回格式:
`js``
{
message: 'SUCCESS',
url: 'xxx'
}