<template>
<div>
<textarea style="display:none" id="editor_content" name="contentHtml"></textarea>
<script id="editor" type="text/plain"></script>
</div>
</template>
<script>
// 导入ueditor相关
import '../../static/UE/ueditor.config.js'
import '../../static/UE/ueditor.all.js'
import '../../static/UE/lang/zh-cn/zh-cn.js'
import '../../static/UE/ueditor.parse.min.js'
export default {
name: 'UE',
data () {
return {
editor: null,
textarea:null,
}
},
props: {
defaultMsg: {
type: String
},
config: {
type: Object
}
},
watch:{
defaultMsg(val) {
const _this = this
if( !this.editor ){
this.editor = window.UE.getEditor('editor', this.config) // 初始化UE
}
this.editor.ready( function() {
_this.editor.setContent(val); // 确保UE加载完成后,放入内容。
_this.$parent._data.htmlDefaultMsg = _this.editor.getContent()
} );
},
},
mounted () {
const _this = this
if( !this.editor ){
this.editor = window.UE.getEditor('editor', this.config) // 初始化UE
}
this.editor.ready( function() {
_this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后,放入内容。
var shellId = 'editor_content'
$('#' + shellId + ' #edui1_toolbarbox').css('display','none');
_this.editor.fireEvent("contentChange");
var $textarea = $('#editor iframe').contents();
var fn = function(){
_this.$parent._data.htmlDefaultMsg = _this.editor.getContent()
}
if (document.all) {
$textarea.get(0).attachEvent('onpropertychange',function(e) {
fn()
});
}else{
$textarea.on('input',fn);
}
})
this.editor.addListener("contentChange",function(){
_this.editor.getContent()
_this.$parent._data.htmlDefaultMsg = _this.editor.getContent()
});

},
methods: {
getUEContent () { // 获取内容方法
this.$parent._data.htmlDefaultMsg = this.editor.getContent()
return this.editor.getContent()
},
setUEContent (Msg) { // 设置内容方法
return this.editor.setContent(Msg)
},
getContentTxt () { // 获取纯文本内容方法
return this.editor.getContentTxt()
},
},
destroyed () {
this.editor.destroy()
}
}
</script>

vue 集成百度富文本编辑器的更多相关文章

  1. vue集成百度富文本编辑器

    1.前期工作,访问百度富文本官网下载相应的百度富文本文件,根据后端用的技术下载相应的版本,建议下载最新版UTF-8版 (有图有真相,看图) https://ueditor.baidu.com/webs ...

  2. Vue集成tinymce富文本编辑器并实现本地化指南(2019.11.21最新)

     tinymce是一款综合口碑特别好.功能异常强大的富文本编辑器,在某些网站,甚至享有"宇宙最强富文本编辑器"的称号.那么,在Vue项目中如何集成呢?这并不困难,只需要参照官方教程 ...

  3. Django集成百度富文本编辑器uEditor

    UEditor是由百度web前端研发部开发所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点,开源基于MIT协议,允许自由使用和修改代码. 首先从ueEditor官网下载最新版本的包, ...

  4. JAVA 集成 Ueditor 百度富文本编辑器

    开发环境:一个简单的SpringMVC框架中,用百度富文本编辑器 ueditor 实现图片和文件的上传 官网地址:http://ueditor.baidu.com/website/ 需要使用到的2个文 ...

  5. ASP.NET MVC + 百度富文本编辑器 + EasyUi + EntityFrameWork 制作一个添加新闻功能

    本文将交大伙怎么集成ASP.NET MVC + 百度富文本编辑器 + EasyUi + EntityFrameWork来制作一个新闻系统 先上截图: 添加页面如下: 下面来看代码部分 列表页如下: @ ...

  6. UEditor百度富文本编辑器--让编辑器自适应宽度的解决方案

    UEditor百度富文本编辑器的initialFrameWidth属性,默认值是1000. 不能够自适应屏幕宽度.如图1: 刚开始的时候,我是直接设置initialFrameWidth=null的.效 ...

  7. 对于MVC中应用百度富文本编辑器问题的解决办法

    1.对于应用富文本编辑器post提交表单内容提示有危险的解决办法: [ValidateInput(false)] //文本编辑器的表单提交不用提示危险 [HttpPost] public Action ...

  8. 在MVC中应用百度富文本编辑器

    1.下载.NET版本的百度富文本编辑器,前往 下载.NET版本百度富文本框 2.解压下载的.zip压缩包,将utf8-.net文件夹名称改为:ueditor,复制到MVC根目录下面.结构如下: App ...

  9. 百度富文本编辑器UEditor安装配置全过程

    网站开发时富文本编辑器是必不可少的,他可以让用户自行编辑内容的样式然后上传到后台!下面我们来介绍如何安装使用百度富文本编辑器 一.下载并且设置百度富文本编辑器的样式     你可以去百度UEditor ...

随机推荐

  1. Javascript 简单实现鼠标拖动DIV

    http://zhangbo-peipei-163-com.iteye.com/blog/1740078 比较精简的Javascript拖动效果函数代码 http://www.jb51.net/art ...

  2. Excle 导入DataSet

    using System.Data.OleDb;using System.Data; public void ReadExcelFiless()        {            //strin ...

  3. DIV滚动样式

    .divScroll{     OVERFLOW:auto;        scrollbar-face-color: #FFFFFF;        scrollbar-shadow-color: ...

  4. 调用WCF错误-There was no endpoint listening

    问题描述: 今天在调用WCF服务时候出现了下面的错误. 原因: 调用服务的客户端ip设置成了固定ip.(至于固定ip为什么会导致这个错误,没能去研究) 解决方法: 将客户端ip设置成自动获取.

  5. java基础--提示对话框的使用

    java基础--提示对话框的使用 2019-03-17-00:35:50-----云林原创 一.显示信息对话框:使用“JOptionPane.showMessageDialog”显示:   图标 对话 ...

  6. HttpClient请求工具类

    package com.yangche.utils; import org.apache.http.NameValuePair; import org.apache.http.client.Clien ...

  7. My first python application

    ''' Authon:WSE_Gordon This application is use for the costomer to login the application. The Costome ...

  8. 选择排序——Java实现

    一.排序思想 选择排序(Selection sort)是一种简单直观的排序算法.它的工作原理是: 从待排序列中选出最小(或最大)的一个元素,记录其下标(数组)的位置: 将记录的下标值与待排序列的第一个 ...

  9. 服务器LIUNX之如何解决矿机问题

    点进来的基本都是遇到liunx变矿机的小伙伴吧(cpu运载300%) 卡的连终端都很难打开 开下来之后提示 大意是, 到xxx网站给钱了事, 不过基本这个网站基本也上不去, 要么是暴力破解, 要么是通 ...

  10. csharp: ClientScript.RegisterStartupScript int net4.0

    //彈出提示 ClientScriptManager cs = Page.ClientScript; StringBuilder sb = new StringBuilder(); sb.Append ...