element-ui + el-dialog + Vue.component 注册的富文本控件 第二次及以后打开dialog出现问题解决方法
Vue.component('my-tinymce', {
props: ['value'],
data(){
return{
flag:true
}
},
watch:{
value(val){
//console.log(val);
if(this.flag){
tinymce.activeEditor.setContent(val);
}
this.flag = true;
}
},
mounted: function(){
const self = this;
tinymce.init({
target: this.$el.children[0],
//theme: 'modern',//inlite mobile modern
language: "zh_CN",
menubar: false,
branding: false,
valid_elements: "p[style],span[style],ul,ol,li,strong/b,em,h1,h2,h3,h4,h5,h6",
valid_style: {
"*":"color,font_size,text-align,line-height"
},
plugins: [ //配置插件:可自己随意选择,但如果是上传本地图片image和imagetools是必要的
'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',
'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
'save table contextmenu directionality emoticons template paste imagetools textcolor'
],
/*表情 emoticons*/
toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | preview media fullpage | forecolor backcolor | code fullscreen | formatselect | table',
// images_upload_url:basePath()+'/platform/res/upload/img',
// images_upload_base_path:'',
// images_upload_credentials:true,
setup: function(editor) {
editor.on('input undo redo execCommand', function(e) {
self.flag = false;
self.$emit('input', editor.getContent());
});
},
images_upload_handler: function (blobInfo, success, failure) {
//console.log(blobInfo);
//console.log(success);
//console.log(failure);
let formData = new FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());
$.ajax({
url : basePath()+'/platform/res/upload/img',
type : "POST",
data : formData,
cache : false,
async : true,
contentType : false, // 这两句需要添加上,否则会跳转页面
processData : false,
dataType : "json",
success : function(obj) {
if(obj.code == 0){
console.log(obj.data.location);
success(obj.data.location);
}else{
failure('上传出错了');
}
},
error : function () {
failure('上传出错了,图片限制上传最大为2M');
}
});
}
});
},
updated(){
},
created(){
},
destroyed(){
},
template: '<div><textarea style="height:300px" v-model="value"></textarea></div>'
});
自定控件 添加属性 v-if="dialogVisible" 或者使用element-ui较新的话可以在在el-dialog 标签上添加 :destroy-on-close="true" 关闭时dialog销毁dialog内的控件
<el-dialog title="" :visible.sync="dialogVisible" :append-to-body="true">
<my-tinymce v-model="data" v-if="dialogVisible"></my-tinymce>
</el-dialog>
这样设置是为了关闭dialog时销毁my-editor控件,不销毁的话会出现问题的
element-ui + el-dialog + Vue.component 注册的富文本控件 第二次及以后打开dialog出现问题解决方法的更多相关文章
- vue+element ui项目总结点(三)富文本编辑器 vue-wangeditor
1.参考 https://www.npmjs.com/package/vue-wangeditor 使用该富文本编辑器 <template> <div class="egi ...
- 036——VUE中表单控件处理之动态绑定文章的属性的处理方法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- VC++如何在程序中用代码注册和卸载ocx控件(代码)
方法一:在dos或Windows命令行下运行:regsvr32 ocxname.ocx 注册 示例:regsvr32 netshare.ocx //注册netshare.ocx控件regsvr ...
- vue单位文本控件与vue加密文本控件
vue单位文本控件: 使用方式: npm install dami-text-input --save 使用: <text-input v-model="test" :uni ...
- Element ui tree结合Vue使用遇到的一些问题(一)
下图是一个后台管理系统,展示的是角色列表 当我点击编辑的时候,弹出一个模态框,如下图 功能需求:点击编辑按钮,弹出模态框,选择权限那块,默认选中当前角色拥有的权限. 问题:第一次点击编辑按钮时,不会选 ...
- Vue 中使用UEditor富文本编辑器-亲测可用-vue-ueditor-wrap
其中UEditor中也存在不少错误,再引用过程中. 但是UEditor相对还是比较好用的一个富文本编辑器. vue-ueditor-wrap说明 Vue + UEditor + v-model 双向绑 ...
- bootstrop 日期控件 datepicker被弹出框dialog覆盖的解决办法
筒子们在使用bootstrap的日期控件(datepicker , 现在官网提供的名称叫 datetimepicker)时可能会遇到如上图的问题这是啥原因造成的呢? 答案很简单时输出的优先级造成的(z ...
- Vue.js学习 Item9 – 表单控件绑定
基础用法 可以用 v-model 指令在表单控件元素上创建双向数据绑定.根据控件类型它自动选取正确的方法更新元素.尽管有点神奇,v-model 不过是语法糖,在用户输入事件中更新数据,以及特别处理一些 ...
- vue中使用kindeditor富文本编辑器
1.去官网下载kindeditor 2.将其放在一个名为kindeditor的文件夹里,并且将它放在vue里的static文件夹下 3.创建kindeditor.vue <template> ...
随机推荐
- input表单元素的默认padding不一致问题
最近做的项目,发现一堆问题,input type=“text”和type=“button” (1)在无文字的时候高度是一致的,分别写入相同大小的文字type=“button”高度>type=“t ...
- LightOJ1282 Leading and Trailing —— 指数转对数
题目链接:https://vjudge.net/problem/LightOJ-1282 1282 - Leading and Trailing PDF (English) Statistics ...
- centos 7 / 6 smokeping安装
官网 值得拥有:http://oss.oetiker.ch/smokeping/doc/reading.en.html 安装依赖包 1 2 yum -y install perl perl-Net-T ...
- WPF-悬浮在底部的导航
先用Rectangle代替导航按钮,这个导航会悬浮在界面的底部,当鼠标移进导航按钮上的时候,按钮会放大,移出后恢复正常. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 ...
- PIL 安装及使用
我ubunto虚拟机自带的是python2.7,好像PIL也只支持到2.7. PIL包的安装 Debian/Ubunto Linux下直接安装: sudo apt-get install python ...
- 数据表示Numpy
1 基本 1.1 基本介绍 掌握表示, 清洗, 统计和展示数据的能力 Numpy, Matplotlib, Pandas, Projects 摘要: 有损的提取数据特征的过程 可以将一组数据, 摘要出 ...
- BZOJ_2208_[Jsoi2010]连通数_强连通分量+拓扑排序+手写bitset
BZOJ_2208_[Jsoi2010]连通数_强连通分量+拓扑排序+手写bitset Description Input 输入数据第一行是图顶点的数量,一个正整数N. 接下来N行,每行N个字符.第i ...
- Java笔记(九)
网络编程: UDP传输: (UdpSend发送端)通过UDP传输方式,将一段文字数据发送出去: (1)建立udpsocket服务 (2)提供数据,并将数据封装到数据包中 (3)通过socket服务的发 ...
- PBE加密算法
这是我参加全国信息安全大赛的设计的加密系统中的一个加密算法,虽然比赛的结果不是非常理想但是,我还是学到了很多东西,现在和大家分享一下,比赛收获的东西. 基于口令加密 PBE(Password Base ...
- js格式
/** * Created by admin on 2017/9/22. */ // 分号后不要再有多余的空格 var name = "North"; var name = &qu ...