今天研究的主角是: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>

下面来看看要实现的效果:

最新文章

  1. Android Studio :enable vt-x in your bios security,已经打开还是报错的解决方法
  2. [SQL] SQL学习笔记之基础操作
  3. 改善你的jQuery的25个步骤 千倍级效率提升
  4. 纯css来画图-border应用
  5. Linux基本权限学习
  6. .htaccess
  7. Ubuntu 16.04 nvidia安装
  8. html的解析
  9. windows上使用image库
  10. UnrealEngine4 PBR Shading Model 概述
  11. JAVA toString方法
  12. 个人.net学习规划路线
  13. 未能从文本&quot;Template&quot;创建 &quot;System.Windows.DependencyProperty&quot;
  14. Qt编译
  15. 简单说明如何设置系统中的NLS_LANG环境变量
  16. 解决python本地离线安装requests问题
  17. 学习oracle存储过程
  18. Java框架spring 学习笔记(十五):操作MySQL数据库
  19. Ubuntu菜鸟入门(十七)—— E: Sub-process /usr/bin/dpkg returned an error code (1) 出错解决方案
  20. vim保存只读文件时获得sudo权限

热门文章

  1. 两个变量交换数字 不用第三个变量的情况下 int a = 5,b = 6
  2. FIT文件CRC校验
  3. layDate——初步使用
  4. .Net Core 商城微服务项目系列(八):购物车
  5. SpringBoot 连接kafka ssl 报 CertificateException: No subject alternative names present 异常解决
  6. win10下使用Linux命令
  7. 阿里云Centos操作Mysql
  8. 利用shell脚本个性化运行jar任务
  9. 每个新手程序员都必须知道的Python技巧
  10. 重载operator new delete函数