vue中使用ueditor富文本编辑框

摘要:
});}, 方法:{getUEContent(){//Get content方法returnthis.editor.getContent()},destroy(){this.editer.destroy);}}在src目录中创建一个新的ue文件,并放置组件ue。vue在ue文件夹中。

1.把下载的Ueditor资源,放入静态资源static中。

vue中使用ueditor富文本编辑框第1张

修改ueditor.config.js中的window.UEDITOR_HOME_URL配置,如下图:

vue中使用ueditor富文本编辑框第2张

2.在main.js中引入以下文件:

import '../static/UE/ueditor.config.js'
import '../static/UE/ueditor.all.min.js'
import '../static/UE/lang/zh-cn/zh-cn.js'
import '../static/UE/ueditor.parse.min.js'

3.创建组件(ue.vue):

<template>
<div>
<script type="text/plain"></script>
</div>
</template>
<script>
export default {
name: 'UE',
data () {
return {
editor: null
}
},
props: {
defaultMsg: {
type: String
},
config: {
type: Object
},

},
mounted() {
const _this = this;
this.editor = UE.getEditor("ueid", this.config); // 初始化UE
this.editor.addListener("ready", function () {
_this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后,放入内容。
});
},
methods: {
getUEContent() { // 获取内容方法
return this.editor.getContent()
}
},
destroyed() {
this.editor.destroy();
}
}
</script>

在src目录下新建一个ue文件,把组件ue.vue放到ue文件夹中。

4.引入组件:

<template>

  <section>

    <UE :defaultMsg='uetest' :config=config ref="ue"></UE>

  </section>

</template>

<script>

  import UE from '@/ue/ue.vue';                   //引入组件

  export default {

    components: {UE},

    data() {

      return {

        uetest:'试一下!!!!',

        config: {
        initialFrameWidth: null,
        initialFrameHeight: 350
        }

      }

  }

  }

</script>

5.效果图

vue中使用ueditor富文本编辑框第3张

 

免责声明:文章转载自《vue中使用ueditor富文本编辑框》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇电商实例、业务并发、网站并发及解决方法龙芯 3A4000 安装 Debian10 (via debootstrap)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

使用vue的v-show和transition制作一个简单轮播图

<template> <!--轮播图--> <div id="carousel"> <transition-group tag="ul" :name="transitionName"> <li v-for="(list,index) in slideList" :key="i...

IDEA工具引入vue项目后配置和运行

*** 不要使用 import 去引入项目,因为不是传统的项目结构 这样打不开,直接使用open 打开文件夹即可。 一、在IDEA中配置vue插件 点击File-->Settings-->Plugins-->搜索vue.js插件进行安装,下面的图中我已经安装好了 二、搭建node.js环境 安装node.js 可以去官网下载:安装过程就...

Vue 基础篇一

Vue框架介绍 之前大家学过HTML,CSS,JS,JQuery,Bootstrap,,现在我们要接触一个新的框架Vue Vue是一个构建数据驱动的web界面的渐进式框架 目标是通过尽可能简单的API实现响应式的数据绑定和组合的视图组件. 能够构建复杂的单页面应用.现在我们开始认识一下Vue // HTML 页面 <div id="app">...

UEditor使用浅析

    UEditor富文本编辑器,百度的良心产品之一。     记录下我是怎么用UEditor的     1、引入到项目中,添加对net/bin下Newtonsoft.json的引用     2、实例化,按照demo中的index.html的形式。把ueditor.config.js和ueditor.all.min.js引过来         此时,应该...

Vue上拉加载下拉刷新---vue-easyrefresh

vue-easyrefresh简介 正如名字一样,EasyRefresh很容易就能在基于Vue的Web应用上实现下拉刷新以及上拉加载操作,支持主流的PC和移动浏览器。它的功能灵感来源于与Android的SmartRefreshLayout,同样也吸取了很多三方库的优点。EasyRefresh中集成了多种风格的Header和Footer,但是它并没有局限性,...

uniapp 中出现 wx.config is not a function

最近使用uniapp做了一个微信公众号网页 调用微信jssdk 报错为wx.config is not a function 我也引用了http://res2.wx.qq.com/open/js/jweixin-1.6.0.js 原因是uniapp里面内置了一个名为wx的全局变量,结果是肯定的,wx变量都被重写了,wx.config肯定也是undefi...