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出现问题解决方法的更多相关文章

  1. vue+element ui项目总结点(三)富文本编辑器 vue-wangeditor

    1.参考 https://www.npmjs.com/package/vue-wangeditor 使用该富文本编辑器 <template> <div class="egi ...

  2. 036——VUE中表单控件处理之动态绑定文章的属性的处理方法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. VC++如何在程序中用代码注册和卸载ocx控件(代码)

    方法一:在dos或Windows命令行下运行:regsvr32 ocxname.ocx 注册 示例:regsvr32 netshare.ocx     //注册netshare.ocx控件regsvr ...

  4. vue单位文本控件与vue加密文本控件

    vue单位文本控件: 使用方式: npm install dami-text-input --save 使用: <text-input v-model="test" :uni ...

  5. Element ui tree结合Vue使用遇到的一些问题(一)

    下图是一个后台管理系统,展示的是角色列表 当我点击编辑的时候,弹出一个模态框,如下图 功能需求:点击编辑按钮,弹出模态框,选择权限那块,默认选中当前角色拥有的权限. 问题:第一次点击编辑按钮时,不会选 ...

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

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

  7. bootstrop 日期控件 datepicker被弹出框dialog覆盖的解决办法

    筒子们在使用bootstrap的日期控件(datepicker , 现在官网提供的名称叫 datetimepicker)时可能会遇到如上图的问题这是啥原因造成的呢? 答案很简单时输出的优先级造成的(z ...

  8. Vue.js学习 Item9 – 表单控件绑定

    基础用法 可以用 v-model 指令在表单控件元素上创建双向数据绑定.根据控件类型它自动选取正确的方法更新元素.尽管有点神奇,v-model 不过是语法糖,在用户输入事件中更新数据,以及特别处理一些 ...

  9. vue中使用kindeditor富文本编辑器

    1.去官网下载kindeditor 2.将其放在一个名为kindeditor的文件夹里,并且将它放在vue里的static文件夹下 3.创建kindeditor.vue <template> ...

随机推荐

  1. DNS常见攻击与防范

    DNS常见攻击与防范 转自:http://www.williamlong.info/archives/3813.html 日期:2015-7-10 随着网络的逐步普及,网络安全已成为INTERNET路 ...

  2. 步入C编程的第一天

    我想学ruby以后开发网站,但ruby是高级语言,隐藏了许多底层的东西,因此先熟悉c语言 首先c程序的文件名是以.c结尾的 c程序的格式: 第一行#include<stdio.h> #是一 ...

  3. Loadrunner脚本自动关联和手动关联

    关于Loadrunner关联一.什么时候需要关联 1.关联的含义        关联(correlation):在脚本回放过程中,客户端发出请求,通过关联函数所定义的左右边界值(也就是关联规则),在服 ...

  4. BZOJ 2023 [Usaco2005 Nov]Ant Counting 数蚂蚁:dp【前缀和优化】

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2023 题意: 有n个家族,共m只蚂蚁(n <= 1000, m <= 1000 ...

  5. hdu-5738 Eureka(组合计数+极角排序)

    题目链接: Eureka Time Limit: 8000/4000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Pr ...

  6. CodeForces - 597C:Subsequences (主席树+DP)

    For the given sequence with n different elements find the number of increasing subsequences with k + ...

  7. Flask-SQLAlchemy配置

    下面是 Flask-SQLAlchemy 中存在的配置值.Flask-SQLAlchemy 从您的 Flask 主配置中加载这些值. 注意其中的一些在引擎创建后不能修改,所以确保尽早配置且不在运行时修 ...

  8. MSTAR GUI

    1.架构 WIN32 SDK ACT->CTL->API->GE/GOP ACT: Customized logic parts CTL: Behavior widgets API: ...

  9. 回味经典——uboot1.1.6 之 第二阶段 第三阶段

    转自:http://blog.csdn.net/lizuobin2/article/details/52061530 上篇文章说到,再清 BSS 段之后,CPU 跳转到 sdram 里的 start_ ...

  10. 从使用os.system)在python命令(重定向标准输入输出

    从使用os.system)在python命令(重定向标准输入输出 python 标准输出stdout stdio os.system通常我可以通过改变sys.stdout的值在python更改标准输出 ...