在vue中使用Ueditor
今天研究的主角是:UEditor
UEditor是由百度WEB前端研发部开发的所见即所得的开源富文本编辑器,具有轻量、可定制、用户体验优秀等特点。
版本有很多

我用的是:[1.4.3.3 PHP 版本] UTF-8版
下载地址:http://ueditor.baidu.com/website/download.html
安装下载之后,将插件解压放在static目录下: static/ue/

修改ueditor.config.js,配置目录 :

ps:这个插件的代码写的真的是”与众不同“,如果你用eslint检查代码,并且是个强迫症患者,那就很欢乐了。
下面是相关代码:
新建组件 /src/base/ueditor/ueditor.vue
<template>
<div>
<script id="editor" type="text/plain"></script>
</div>
</template>
<script>
export default {
name: "ue",
data() {
return {
editor: null
};
},
props: {
value: "",
config: {}
},
mounted() {
const _this = this;
this.editor = window.UE.getEditor("editor", this.config);
// 初始化UE
this.editor.addListener("ready", function() {
_this.editor.setContent(_this.value);
// 确保UE加载完成后,放入内容。
});
},
methods: {
getUEContent() {
// 获取内容方法
return this.editor.getContent();
}
},
destroyed() {
this.editor.destroy();
}
};
</script>
在组件中引用
<template>
<div>
<Ueditor :value="ueditor.value" :config="ueditor.config" ref="ue"></Ueditor>
<input type="button" value="显示编辑器内容(从控制台查看)" @click="returnContent">
</div> </template> <script>
import Ueditor from "../../base/ueditor/ueditor";
export default {
data() {
return {
dat: {
content: "",
},
ueditor: {
value: "编辑默认文字",
config: {}
}
};
},
methods: {
returnContent() {
this.dat.content = this.$refs.ue.getUEContent();
console.log(this.dat.content);
},
showContent() {
this.show = !this.show;
}
},
components: {
Ueditor
}
};
</script>
下面来看看要实现的效果:

在vue中使用Ueditor的更多相关文章
- vue中使用Ueditor编辑器
一. 下载包: 从Ueditor的官网下载1.4.3.3jsp版本的Ueditor编辑器,官网地址为: http://ueditor.baidu.com/website/ 下载解压后会得到如果下文 ...
- Vue 中使用UEditor富文本编辑器-亲测可用-vue-ueditor-wrap
其中UEditor中也存在不少错误,再引用过程中. 但是UEditor相对还是比较好用的一个富文本编辑器. vue-ueditor-wrap说明 Vue + UEditor + v-model 双向绑 ...
- vue中使用ueditor富文本编辑框
1.把下载的Ueditor资源,放入静态资源static中. 修改ueditor.config.js中的window.UEDITOR_HOME_URL配置,如下图: 2.在main.js中引入以下文件 ...
- vue中使用UEditor编辑器 -- 2
1:下载ueditor下来,放在vue项目中的static文件夹下 2:创建ueditor编辑界面 3:椰~~~~~此时已经可以使用了 但是你会发现 (黑人脸)what the fuck??? ...
- vue中使用Ueditor编辑器 -- 1
一. 下载包: 从Ueditor的官网下载1.4.3.3jsp版本的Ueditor编辑器,官网地址为:http://ueditor.baidu.com/website/download.html ...
- laravel+vue组合的项目中引入ueditor(打包成组件形式)
前言:最近写东西需要用到ueditor,并且需要是在vue组件中引入. (本博客默认你已经配置了laravel+vue的项目环境,如果还没有配置好的的小伙伴,可以看看我的另一篇博客,链接: http: ...
- 在vue中创建多个ueditor实例
简介 在vue中创建多个ueditor实例,我使用neditor,其实就是把ueditor样式美化了下,其他和ueditor几乎一样 截图 源码地址 https://github.com/oblivi ...
- nodejs+mongodb+vue前后台配置ueditor
笔者在做一个个人博客项目的时候需要一个富文本框输入组件与后台进行交互,但是官方配置里面没有关于nodejs的,于是自己查阅资料研究了一下,最后终于应用到了系统中. 一.后台配置 首先是找到了这个项目: ...
- vue集成百度UEditor富文本编辑器
在前端开发的项目中.难免会遇到需要在页面上集成一个富文本编辑器.那么.如果你有这个需求.希望可以帮助到你 vue是前端开发者所追捧的框架,简单易上手,但是基于vue的富文本编辑器大多数太过于精简.于是 ...
随机推荐
- 通过python代码对域名ssl证书进行监控
根据公司要求,要求用zabbix对域名的ssl证书进行到期监控 直接上代码 #!/usr/bin/env python3 from urllib3.contrib import pyopenssl f ...
- 学习WEBAPI第一天
目录 WebApi: 通过操作对象来实现操作标签的目的 一.DOM 中常用的操作 二.doucument对象 三.获取元素 四.注册事件 五.操作元素的属性 六.当页面加载完时,script代码已经执 ...
- Spring boot 官网学习笔记 - 开发第一个Spring boot web应用程序(使用mvn执行、使用jar执行)
Creating the POM <?xml version="1.0" encoding="UTF-8"?> <project xmlns= ...
- jQuery常用方法(一)-基础
$("p").addClass(css中定义的样式类型); 给某个元素添加样式 $("img").attr({src:"test.jpg", ...
- Kafka 学习笔记之 Producer/Consumer (Scala)
既然Kafka使用Scala写的,最近也在慢慢学习Scala的语法,虽然还比较生疏,但是还是想尝试下用Scala实现Producer和Consumer,并且用HashPartitioner实现消息根据 ...
- 02-13 Softmax回归
目录 Softmax回归 一.Softmax回归详解 1.1 让步比 1.2 不同类之间的概率分布 1.3 目标函数 1.4 目标函数最大化 二.Softmax回归优缺点 2.1 优点 2.2 缺点 ...
- JS中的prototype、__proto__与constructor
1.前言 作为一名前端工程师,必须搞懂JS中的prototype.__proto__与constructor属性,相信很多初学者对这些属性存在许多困惑,容易把它们混淆,本文旨在帮助大家理清它们之间的关 ...
- 利用Helm简化Kubernetes应用部署(2)
目录 定义Charts 使用Helm部署Demo Helm常用操作命令 定义Charts 回到之前的“charts”目录,我们依次进行解读并进行简单的修改. Chart.yaml 配置示例: a ...
- 洛谷 P1717 钓鱼
题目描述 话说发源于小朋友精心设计的游戏被电脑组的童鞋们藐杀之后非常不爽,为了表示安慰和鼓励,VIP999决定请他吃一次“年年大丰收”,为了表示诚意,他还决定亲自去钓鱼,但是,因为还要准备2013NO ...
- 一次SSM项目记录
1.控制台输入 mvn archetype:generate -DgroupId=com.yjdev -DartifactId=myzone -DarchetypeArtifactId=maven-a ...