wangEditor编辑器 Vue基本配置项
wangEditor编辑器 Vue基本配置项
1.Vue安装方法
npm i wangeditor -S
<template>
<div id='wangeditor'>
<div id="editor">
<!-- <p>欢迎使用 <b>wangEditor</b> 富文本编辑器</p> -->
</div>
<button @click="updata">提交啊</button>
</div>
</template> <script>
import E from "wangEditor";
import 'wangeditor/release/wangEditor.min.css'
// wangEditor配置按钮菜单
const btnmenu = [
'head',//标题
'bold',//粗体
'fontSize',//字号
'fontName',//字体
'italic',//斜体
'undeline',//下划线
'strikeThrough',//删除线
'foreColor',//文字颜色
'backColor',//背景颜色
'link',//插入链接
'list',//列表
'justify',//对齐方式
'quote',//引用
'emoticon',//表情
'image',//插入图片
'table',//表格
'video',//插入视频
'code',//插入代码
'undo', //撤销
'redo', // 重复
]
export default {
name:'wangeditor',
// model:{
// prop:'value',
// event:'change',
// },
// props:{
// value:{
// type:String,
// default:''
// },
// isClear:{
// type:Boolean,
// default:''
// }
// },
data() {
return {
exconten:'',
editor:'',
info:'',
}
},
mounted(){ this.editor = new E('#editor');
// 自定义菜单配置
this.editor.customConfig.menus = btnmenu;
// 配置上传图片为base64
this.editor.customConfig.uploadImgShowBase64=false;
// 配置图片上传服务器
this.editor.customConfig.uploadImgServer='/upload';
// 隐藏“网络图片”tab
this.editor.customConfig.showLinkImg = false
// withCredentials(跨域传递 cookie)
this.editor.customConfig.withCredentials = true;
// 自定义header
this.editor.customConfig.uploadHeader={};
// 后端接收上传文件的参数名
this.editor.customConfig.uploadFileName='';
// 将图片大小限制为2M
this.editor.customConfig.uploadImgMaxSize=2*1024*1024;
// 限制最多上传6张图片
this.editor.customConfig.uploadImgMaxLength=6;
// 设置超时
this.editor.customConfig.uploadImgTimeout=3*60*1000;
// 关闭粘贴样式的过滤
this.editor.customConfig.pasteFilterStyle = false;
// 忽略粘贴内容中的图片
this.editor.customConfig.pasteIgnoreImg = true;
// 自定义处理粘贴的文本内容
this.editor.customConfig.pasteTextHandle = function (content) {
// content 即粘贴过来的内容(html 或 纯文本),可进行自定义处理然后返回
// return content + '<p>在粘贴内容后面追加一行</p>'
return content;
}
// url 即插入图片的地址(插入网络图片的回调)
this.editor.customConfig.linkImgCallback = function (url) {
console.log(url)
}
// 插入链接的校验
this.editor.customConfig.linkCheck = function (text, link) {
console.log(text) // 插入的文字
console.log(link) // 插入的链接
return true // 返回 true 表示校验成功
// return '验证失败' // 返回字符串,即校验失败的提示信息
}
// 插入网络图片的校验
this.editor.customConfig.linkImgCheck = function (src) {
console.log(src) // 图片的链接
return true // 返回 true 表示校验成功
// return '验证失败' // 返回字符串,即校验失败的提示信息
}
// 创建富文本编辑器
this.editor.create()
// 获取富文本内容
this.editor.txt.html();
// 编辑区域的z-index默认为100
this.editor.customConfig.zIndex = 100;
// 图片上传回调
this.editor.customConfig.uploadImgHooks={
fail:(xhr,editor,result)=>{/**插入图片回调失败 */},
success:(xhr,editor,result)=>{/**图片上传成功回调 */},
timeout:(xhr,editor,result)=>{/**网络超时回调 */},
error:(xhr,editor,result)=>{/**图片上传错误回调 */},
customInsert:(insertImg,result,editor)=>{/**图片上传成功,插入图片回调 */}
}
// 上传图片的错误提示默认使用alert弹出,你也可以自定义用户体验更好的提示方式
this.editor.customConfig.customAlert = function (info) {
// info 是需要提示的内容
alert('自定义提示:' + info);
console.log(info);
}
this.editor.customConfig.customUploadImg = function (files, insert) {
// files 是 input 中选中的文件列表
// insert 是获取图片 url 后,插入到编辑器的方法 // 上传代码返回结果之后,将图片插入到编辑器中
insert(imgUrl)
}
// 监听实时富文本输入内容
// this.editor.customConfig.onchange=(html)={
// let info=html;
// this.$emit('change',info);
// }
},
methods:{
updata(){
alert(this.editor.txt.html());
this.editor.txt.html('');
}
},
// watch:{
// isClear(val){
// // 触发清除文本域内容
// if(val){
// this.editor.txt.clear();
// this.info = '';
// }
// },
// value(val){
// // 使用v-model时,设置初始值
// this.editor.txt.html(val);
// }
// }
}
</script> <style> </style>
wangEditor编辑器 Vue基本配置项的更多相关文章
- Java web 引入wangEditor编辑器
最近项目需要我做些前端的事,这让我这个半吊子前端很是痛苦.项目中需要一个编辑器,之前找了个ueditor,插件比较多,需要改源码等等不说,最后弄好了,发现需要flash插件.没办法,只有推到重来,在网 ...
- PHP UEditor富文本编辑器 显示 后端配置项没有正常加载,上传插件不能正常使用
UEditor是由百度web前端研发部开发所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点,开源基于MIT协议,允许自由使用和修改代码... 问题描述 我的编辑器在本地测试的时候没问 ...
- 修改vue的配置项支持生产环境下二级目录访问的方法
本文主要记录如何配置vue的打包文件配置项,使打包后的文件可以支持二级目录的访问. 1.常规打包 在实际的项目中,我们通常都使用 npm run build 直接打包文件后丢到服务器上访问 打包后的文 ...
- wangEditor编辑器中解析html图文信息问题
在JS中,有一种方法:innerHTML 属性设置或返回表格行的开始和结束标签之间的 HTML. 也就是说,我们可以利用这个属性,把字符串转换为html代码,这样就可以被解析了. 其次,我们是需要在页 ...
- 集成百度编辑器 ueditor 后端配置项没有正常加载,上传插件不能正常使用!
项目要用到编辑器,于是集成了ueditor,集成ok,但一直显示 ‘’后端配置项没有正常加载,上传插件不能正常使用!‘’ 各种查: 网上说的无非就是那么集中情况 1. 因为百度官方的问题,php/co ...
- 前端富文本编辑器vue + tinymce
之前有项目需要用到富文本编辑器,在网上找了好几个后,最终选择了这个功能强大,扩展性强的tinymce tinymce中文文档地址(不全):http://tinymce.ax-z.cn/ tinymce ...
- vue 函数配置项watch以及函数 $watch 源码分享
Vue双向榜单的原理 大家都知道Vue采用的是MVVM的设计模式,采用数据驱动实现双向绑定,不明白双向绑定原理的需要先补充双向绑定的知识,在watch的处理中将运用到Vue的双向榜单原理,所以 ...
- wangEditor编辑器控件里textarea的id不要用content
头引用 <script type="text/javascript" src="js/jquery-1.10.2.min.js"></scri ...
- 一款好用的wangEditor编辑器
文档:https://www.kancloud.cn/wangfupeng/wangeditor3/332599
随机推荐
- .net core 设置访问静态资源
- Python协程与asyncio
asyncio(解决异步io编程的一整套解决方案,它主要用于异步网络操作.并发和协程)协程(Coroutine一种用户态的轻量级微线程,它是程序级别的,在执行过程中可以中断去执行其它的子程序,别的子程 ...
- windows控件理论学习
mmp快考试了还在浪 一.对话框编辑器创建控件 1.使用new在堆上创建,系统结束时我们需要使用delete去销毁控件 2.对话框编辑器控件,程序结束,自动销毁 二.控件类的基类 CWnd类和消息映射 ...
- 解决'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
懒癌晚期,直接贴图 然后就解决了!
- 教你正确打开async/await关键字的使用
这段时间在项目开发中看到了一些async/await的使用,在aspnet core的host组件源码中也看到了许多的async/await代码.在开发时,正确的使用了async/await是可以提高 ...
- Android应用程序MVC框架实例分析
问题提出:如何优雅地分离出应用程序的状态.用户交互和数据表现?如何通过框架体现工程的高性能.高灵活性.高响应性? MVC定义:model.view.controller三者的有机组合,分别表示:模型. ...
- 如何在 code blocks中使用 mkl库
为了安装caffe, 所以安装了mkl, 现在想在codeblock的项目中使用mkl. 设置mkl环境变量: mkl安装好后默认是在/opt/intel/mkl中,其中/opt/intel/mkl/ ...
- C#创建ActiveX
因为最近的项目可能会用到调用外部设备,读取信息.为了和现有的BS系统兼容,并以较小的代价满足需求,于是想到了使用ActiveX技术(也有人建议使用Silverlight),这技术虽然比较早了,但还是能 ...
- python#读csv,excel,json数据
#读csv,excel,json数据 with open('E:\\test\\xdd.csv','r') as f: for line in f.readlines(): print(line) i ...
- swift中Cell的内容定制
1.cellForTitle 2.register