不去做怎么知道做不到,用心做好每一天做好每一件事。|

轻风细雨_林木木

园龄:6年3个月粉丝:4关注:1

vue-ueditor-wrap 是什么?怎么使用?

前言

vue-ueditor-wrap 是什么

一个“包装”了 UEditor 的 Vue 组件,支持通过 v-model 来绑定富文本编辑器的内容,让 UEditor 的使用简单到像 Input 框一样。

UEditor 并不支持通过 npm 的方式来安装,vue-ueditor-wrap 也只是一个 Vue 组件,组件本身并不是 UEditor 的 Vue 版。

手册

地址:https://www.npmjs.com/package/vue-ueditor-wrap

Installation 安装

  1. 安装组件
# vue-ueditor-wrap v2 仅支持 Vue 2
npm i vue-ueditor-wrap@2.x
# 或者
yarn add vue-ueditor-wrap@2.x
  1. 引入VueUeditorWrap组件
import VueUeditorWrap from 'vue-ueditor-wrap'; // ES6 Module
// 或者
const VueUeditorWrap = require('vue-ueditor-wrap'); // CommonJS
  1. 注册组件
components: {
VueUeditorWrap;
}
// 或者在 main.js 里将它注册为全局组件
Vue.component('vue-ueditor-wrap', VueUeditorWrap);
  1. v-model绑定数据
<vue-ueditor-wrap v-model="msg"></vue-ueditor-wrap>
data () {
return {
msg: '<h2>Hello World!</h2>'
}
}
  1. 配置

完整配置请参考 ueditor.config.js官方文档

<vue-ueditor-wrap v-model="msg" :config="editorConfig" editor-id="editor-demo-01"></vue-ueditor-wrap>
data() {
return {
msg: "<h2>Hello World!</h2>",
editorConfig: {
// 访问 UEditor 静态资源的根路径,可参考 https://hc199421.gitee.io/vue-ueditor-wrap/#/faq
UEDITOR_HOME_URL: "/UEditor/",
// 服务端接口(这个地址是我为了方便各位体验文件上传功能搭建的临时接口,请勿在生产环境使用!!!)
serverUrl: "//ueditor.szcloudplus.com/cos",
},
};
},

Events 事件

事件名说明回调参数
before-init在 UEditor 的 scripts 加载完毕之后、编辑器初始化之前触发editorId: string
readyUEditor ready 时触发editor: UEditor 实例

本文作者:轻风细雨_林木木

本文链接:https://www.cnblogs.com/linzhifen5/p/17240874.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   轻风细雨_林木木  阅读(365)  评论(0编辑  收藏  举报  
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 尚好的青春 孙燕姿
  2. 2 孙燕姿
  3. 3 克卜勒 孙燕姿
- 孙燕姿
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.