今天研究的主角是:UEditor

UEditor是由百度WEB前端研发部开发的所见即所得的开源富文本编辑器,具有轻量、可定制、用户体验优秀等特点。

版本有很多

我用的是:[1.4.3.3 PHP 版本] UTF-8版

下载地址:http://ueditor.baidu.com/website/download.html

安装下载之后,将插件解压放在static目录下: static/ue/

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

window.UEDITOR_HOME_URL = "/static/ue/";

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的更多相关文章

  1. vue中使用Ueditor编辑器

    一.   下载包: 从Ueditor的官网下载1.4.3.3jsp版本的Ueditor编辑器,官网地址为: http://ueditor.baidu.com/website/ 下载解压后会得到如果下文 ...

  2. Vue 中使用UEditor富文本编辑器-亲测可用-vue-ueditor-wrap

    其中UEditor中也存在不少错误,再引用过程中. 但是UEditor相对还是比较好用的一个富文本编辑器. vue-ueditor-wrap说明 Vue + UEditor + v-model 双向绑 ...

  3. vue中使用ueditor富文本编辑框

    1.把下载的Ueditor资源,放入静态资源static中. 修改ueditor.config.js中的window.UEDITOR_HOME_URL配置,如下图: 2.在main.js中引入以下文件 ...

  4. vue中使用UEditor编辑器 -- 2

    1:下载ueditor下来,放在vue项目中的static文件夹下   2:创建ueditor编辑界面 3:椰~~~~~此时已经可以使用了 但是你会发现   (黑人脸)what the fuck??? ...

  5. vue中使用Ueditor编辑器 -- 1

    一.   下载包: 从Ueditor的官网下载1.4.3.3jsp版本的Ueditor编辑器,官网地址为:http://ueditor.baidu.com/website/download.html ...

  6. laravel+vue组合的项目中引入ueditor(打包成组件形式)

    前言:最近写东西需要用到ueditor,并且需要是在vue组件中引入. (本博客默认你已经配置了laravel+vue的项目环境,如果还没有配置好的的小伙伴,可以看看我的另一篇博客,链接: http: ...

  7. 在vue中创建多个ueditor实例

    简介 在vue中创建多个ueditor实例,我使用neditor,其实就是把ueditor样式美化了下,其他和ueditor几乎一样 截图 源码地址 https://github.com/oblivi ...

  8. nodejs+mongodb+vue前后台配置ueditor

    笔者在做一个个人博客项目的时候需要一个富文本框输入组件与后台进行交互,但是官方配置里面没有关于nodejs的,于是自己查阅资料研究了一下,最后终于应用到了系统中. 一.后台配置 首先是找到了这个项目: ...

  9. vue集成百度UEditor富文本编辑器

    在前端开发的项目中.难免会遇到需要在页面上集成一个富文本编辑器.那么.如果你有这个需求.希望可以帮助到你 vue是前端开发者所追捧的框架,简单易上手,但是基于vue的富文本编辑器大多数太过于精简.于是 ...

随机推荐

  1. Redis-->Ubutn上的安装教程

    Redis 安装 当前redis最新稳定版本是4.0.9 以下步骤可以跳过 最新稳定版本下载链接:http://download.redis.io/releases/redis-4.0.9.tar.g ...

  2. Angular 路由守卫

    1. 路由 Angular路由: 可以控制页面跳转:可以在多视图间切换: 2. 路由守卫 Angular路由守卫: 在进入或离开某路由时,用于判断是否可以离开.进入某路由::: return true ...

  3. 学习VBA

    学习VBA VBA 就是 (Visual basic for Application) 用的比较多的是在Excel中处理数据,可以方便快捷地使用编程方式来对数据进行操作. VBA 数据类型 Integ ...

  4. 排坑日记之批量从库IO进程停止

    早上刚睁眼,看到了一堆数据库告警的短信,其中一个内容如下: Problem started at 05:02:58 on 2019.10.12 Problem name: Slave is stopp ...

  5. 设计一个A表数据抽取到B表的抽取过程

    原题如下: 解题代码如下: table1类: @Data @NoArgsConstructor @AllArgsConstructor public class table1{ private Str ...

  6. INTELLIJ MAC查看类结构快捷键

    mac下intellij查看类结构快捷键有两种形式. 方法一 alt+7,通过窗口展示类结果,点击对应的方法,类中跳转到对应的位置,但此窗口并不会消失.如下图: 方法二 默认使用command+F12 ...

  7. java工具类之Arrays、Collections以及比较器

    一.Comparable和Comparator的详解 Comparable & Comparator 都是用来实现集合中元素的比较.排序的,只是 Comparable 是在集合内部定义的方法实 ...

  8. idea破解版安装、配置jdk以及建立一个简单的maven工程

    idea破解版安装.配置jdk,配置jdk环境变量以及建立一个简单的maven工程 一.idea破解版以及配置文件下载 下载网址:https://pan.baidu.com/s/1yojA51X1RU ...

  9. /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:118:in `git_version': Failed to extract git version from `git --version`

    问题及分析 今天做项目的时候,执行pod update报了如下错误信息: /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.5.3/lib/cocoapo ...

  10. Tomcat基本知识(一)

    顶层架构先上一张Tomcat的顶层结构图(图A),如下: Tomcat中最顶层的容器是Server,代表着整个服务器,从上图中可以看出,一个Server可以包含至少一个Service,用于具体提供服务 ...