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. Idea操作与问题解决

    1,.properties文件汉字编码出错 主要是Editer的Encoding出错,可在File->settings->Editer->FileEncoding中修改为: 可参考: ...

  2. netstat 参数

    Netstat用于显示与IP.TCP.UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况. NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] ...

  3. 基于BASYS2的VHDL程序——数字钟(改进版)

    扩展到时分秒.加了入调时电路,但不知道为什么有两个按键不好使.而且不知道以何种方式假如按键消抖电路,因为加入后会多个时钟控制一个信号,物理不可实现.调试电路待解决.还有,四个数目管中间的那两个圆点怎么 ...

  4. codeforces 465C.No to Palindromes! 解题报告

    题目链接:http://codeforces.com/problemset/problem/464/A 题目意思:给出一个长度为 n 且是 tolerable 的字符串s,需要求出字典序最小的长度也为 ...

  5. powershell 扩展 (PSCX) 安装指南

    在玩ansible的过程中,使用win_unzip模块时powershell支持不了,需要安装PSCX对powershell进行扩展,随手记录下安装过程. 从官网下载的Pscx是一个zip压缩文件,解 ...

  6. java学习之super关键字

    对于具有public或者protected属性的父类,其子类若想继承父亲的属性或者方法,那么需要用到super 实例:

  7. hdu-3018 Ant Trip(欧拉路径)

    题目链接: Ant Trip Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others) ...

  8. 安装tensorflow-gpu出现的问题

    1.Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/l ...

  9. IOS造成卡顿的主要原因

    1. cellForRowAtIndexPath, 单元格视图重用, 注意尽量让所有视图重用, 只根据单元格row和section的不容更换不同的数据, 而不是每次都生成新的单元格, 这是程序奔溃的前 ...

  10. UItextFied 的属性

    网络学习笔记 在iPhone应用中通过UITextField填写信息时,经常出现出现自动更正输入信息.首字母大写等情况 尤其是在填写用户名时,这种本想提供便捷的功能反而让人感到特别麻烦 今天查了相关书 ...