VUE中引入UEditor富文本编辑器

本文介绍了如何在Vue项目中集成UEditor富文本编辑器。首先将UEditor资源放入src/static,然后封装为ueditor.vue组件,最后在需要的地方引用此组件。
摘要由CSDN通过智能技术生成

vue中引入ueditor

1.放入静态资源并配置

首先把官网下载的Ueditor资源,放入静态资源src/static中。(你的U盘里有,不用下载了)

 

 

2.封装一个组件 ueditor.vue ,放到src/components/里

<template>
  <div>
    <script id="editor" type="text/plain"/>
  </div>
</template>

<script>
import '../../static/ueditor/ueditor.config.js'
import '../../static/ueditor/ueditor.all.js'
import '../../static/ueditor/lang/zh-cn/zh-cn.js'
import '../../static/ueditor/ueditor.parse.min.js'

export default {
  props: {
    initData: {
      type: String
    }
  },

  data () {
    return {
      editor: null
    }
  },

  watch: {
    initData: function (val) {
      let con = val ? val : ''
      this.editor.ready(() => {
        this.editor.setContent(con)
      })
    }
  },

  mounted () {
    this.setConfig()
  },

  methods: {
    // 获取内容
  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值