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> ...
随机推荐
- spring定时器的配置
首先,新建一个java项目,下面导入需要的jar包: 这里有你需要的jar包哦. jar包下载 在src文件夹下,新建一个applicationContext.xml文件 <?xml versi ...
- 【Effective C++】资源管理
资源:动态分配的内存.文件描述器.互斥锁.图形界面中的字型与笔刷.数据库连接以及网络sockets等,无论哪一种资源,重要的是,当你不再使用它时,必须将它还给系统. 条款13:以对象管理资源 当我们向 ...
- leetcode 747. Largest Number At Least Twice of Others
In a given integer array nums, there is always exactly one largest element. Find whether the largest ...
- async函数学习笔记
含义 async函数是什么?一句话,它就是Generator函数的语法糖. const fs = require('fs') const readFile = function(fileName){ ...
- 微信 jssdk 逻辑在 vue 中的运用
微信 jssdk 在 vue 中的简单使用 import wx from 'weixin-js-sdk'; wx.config({ debug: true, appId: '', timestamp: ...
- [RK3288][Android6.0] 调试笔记 --- eMMC分区号和名字的对应【转】
本文转载自:http://blog.csdn.net/kris_fei/article/details/77318410 Platform: Rockchip OS: Android 6.0 Kern ...
- U盘安装Ubuntu 14.04 LTS正式版 出现如下的提示,不能继续,如何操作?
I had a problem (minor annoyance) when booting up Arch linux with a USB drive connected. The problem ...
- !function(){}()和function(){}()区别
控制台打印结果如下所示,接下来看一下具体运行,参考https://swordair.com/function-and-exclamation-mark/: 让一个函数声明语句变成了一个表达式
- Keras 可视化 model
参考:https://keras.io/visualization/ error解决参考:http://blog.csdn.net/wangjian1204/article/details/50346 ...
- object_test.py
#方法,属性,私有化加双下划线 ''' __a 从外部无法访问,但是类的内部可以访问.实际上还是能在类外访问这些私有方法,尽管不应该这么做:s._A__a 如果不需要使用这种方法但是又不行让其他对象不 ...