1. 本组件基于 wangeditor

http://www.wangeditor.com/

如有侵权 请告知,

2. 效果图

3. 依赖安装

package.json 中 devDependencies

    或者直接  npm install  wangeditor --save-dev

  2.  引入

<script>

  import Editor from '@/components/Editor/Editor'

</script>

3.注册组件 && 获取组件编辑数据

export default {

components: {

Editor

},

data() {

return {

editorData: ''

}

},

methods: {

getEditorData(val) {

this.editorData = val

}

}

}

4. HTML中写入

<template>

<div>

...

<Editor @getEditorData="getEditorData"></Editor>

</div>

</template>

5. 源码:

<template>
<div class="editorWrap">
<div id="editorElem" style="text-align:left"></div>
<div id="submit" :style="'height:' + submitHeight + 'px;line-height:' + submitHeight + 'px;'" v-on:click="getContent">提交</div>
</div>
</template> <script>
import E from 'wangeditor' export default {
name: 'editor',
data() {
return {
editorContent: '',
submitHeight: 30
}
},
methods: {
getContent: function() {
this.$emit('getEditorData', this.editorContent)
}
},
mounted() {
const editor = new E('#editorElem')
editor.customConfig.onchange = (html) => {
this.editorContent = html
}
editor.customConfig.uploadImgShowBase64 = true // 使用 base64 保存图片
// editor.customConfig.uploadImgServer = '/upload' // 上传图片到服务器
editor.create()
this.submitHeight = document.getElementsByClassName('w-e-toolbar')[0].offsetHeight
}
}
</script> <style lang="scss">
.editorWrap {
position: relative;
#submit {
position: absolute;
top: 0;
right: 0;
width: 60px;
text-align: center;
cursor: pointer;
}
#submit:hover {
color: #00b7ee;
}
.w-e-text-container {
z-index: 200!important;
}
}
</style>

  git 地址:https://github.com/IceGogh/vue-components

  

vue2.0 富文本组件(基于wangeditor)的更多相关文章

  1. 基于vue2.0的分页组件开发

    今天安排的任务是写基于vue2.0的分页组件,好吧,我一开始是觉得超级简单的,但是越写越写不出来,写的最后乱七八糟的都不知道下句该写什么了,所以重新捋了思路,小结一下- 首先写组件需要考虑: 要从父组 ...

  2. Angular封装WangEditor富文本组件

    富文本组件是web程序中很常用的一个组件,特别是要开发一个博客,论坛这类的网站后台. 得益于Angular的强大,封装WangEditor组件非常简单 1.使用yarn或者npm安装wangedito ...

  3. Vue2.0的通用组件

    饿了么基于Vue2.0的通用组件开发之路(分享会记录)   Element:一套通用组件库的开发之路 Element 是由饿了么UED设计.饿了么大前端开发的一套基于 Vue 2.0 的桌面端组件库. ...

  4. vue2.0实现分页组件

    最近使用vue2.0重构项目, 需要实现一个分页的表格, 没有找到合适的组件, 就自己写了一个, 效果如下: 该项目是使用 vue-cli搭建的, 如果你的项目中没有使用webpack,请根据代码自己 ...

  5. iOS富文本组件的实现—DTCoreText源码解析 数据篇

    本文转载 http://blog.cnbang.net/tech/2630/ DTCoreText是个开源的iOS富文本组件,它可以解析HTML与CSS最终用CoreText绘制出来,通常用于在一些需 ...

  6. Extjs6 编写自己的富文本组件(以ueditor为基础)

    一.下载ueditor 地址:http://ueditor.baidu.com/website/ 二.将ueitor资源引入自己的项目 在index.html中引入ueditor.config.js. ...

  7. vue2.0 之文本渲染-v-html、v-text

    vue2.0 之文本渲染-v-html.v-text 1.index.html代码 <!DOCTYPE html> <html> <head> <meta c ...

  8. 【rich-text】 富文本组件说明

    [rich-text] 富文本组件可以显示HTML代码样式. 1)支持事件:tap.touchstart.touchmove.touchcancel.touchend和longtap 2)信任的HTM ...

  9. 支付宝小程序开发——rich-text富文本组件支持html代码

    前言: 与微信小程序不同,支付宝小程序的富文本组件并不能直接支持html代码,如: 如上,支付宝小程序的富文本组件只支持数组类型,html代码需要使用 mini-html-parser 转换,具体用法 ...

随机推荐

  1. postgresql + JDBC 学习

    Based on debian 9, postgresql 9.6 and Java 8, at Dec-24-2018 ======================================= ...

  2. C++&Win32写的空当接龙

    上学期做课程设计,老师让我做windows自带的空当接龙游戏,写了一个礼拜,完全仿windows的呵呵.不过也不全一样,有一些细节一直没有时间弄,没办法最近比较懒... 与windows下的相比,我做 ...

  3. strlen源码剖析(可查看glibc和VC的CRT源代码)

    学习高效编程的有效途径之一就是阅读高手写的源代码,CRT(C/C++ Runtime Library)作为底层的函数库,实现必然高效.恰好手中就有glibc和VC的CRT源代码,于是挑了一个相对简单的 ...

  4. win7访问部分win2003速度慢

    解决办法: 关闭TCPIP协议的自动优化调整功能,在win7上,以管理员身份运行cmd,输入 netsh interface tcp set global autotuninglevel=disabl ...

  5. bootstrap组件和插件

    一.用node.js读取文件 //引入fs模块 var fs= require ('fs'); // console.log(fs); //调用fs模块的readFile方法 fs.readFile( ...

  6. ChannelPipeline----贯穿io事件处理的大动脉

    ChannelPipeline贯穿io事件处理的大动脉 上一篇,我们分析了NioEventLoop及其相关类的主干逻辑代码,我们知道netty采用线程封闭的方式来避免多线程之间的资源竞争,最大限度地减 ...

  7. java代码块牛刀小试

    牛刀小试1. 试一把静态代码块.实例化代码块和构造函数的执行顺序 public class People { public static int num = 0;//静态变量初始化 String na ...

  8. Docker配置容器位置和小技巧

    Docker使用小技巧 清理全部停止的docker容器 有时候我们会有很多已经停止的容器或者由于错误强制退出不能用的容器,那我们就需要删除了,但是我们一个一个的rm删除很麻烦,有多少容器就要rm多少次 ...

  9. 【设计模式】行为型08状态模式(status Pattern)

    状态模式(status Pattern)       定义:允许一个对象在其内部状态改变时改变它的行为,对象看起来似乎修改了它的类.其别名为状态对象(Objects for States).与命令模式 ...

  10. Codeforces Round #563 (Div. 2)B

    B.Ehab Is an Odd Person 题目链接:http://codeforces.com/contest/1174/problem/B 题目 You’re given an array a ...