vue结合百度UEditor富文本编辑器实现vue-ueditor-wrap

1.下载vue-ueditor-wrap

cnpm i vue-ueditor-wrap -S

下载最新的 UEditor 资源文件放入你项目的静态资源目录中(比如 static 或者 public,这取决于你项目的配置)。

2.引入VueUeditorWrap组件

import VueUeditorWrap from 'vue-ueditor-wrap'

3.注册组件

components: {
  VueUeditorWrap
}
// 或者在 main.js 里将它注册为全局组件
Vue.component('vue-ueditor-wrap',VueUeditorWrap)

4.v-model绑定数据

<vue-ueditor-wrap v-model="msg"></vue-ueditor-wrap>

5.示例

<template>
  div class="hello">
    vue-ueditor-wrap ref="ueditor" v-model="msg" :destroy="false" :config="config" style="width: 600px;margin: 0 auto;"></vue-ueditor-wrapbutton @click="showData" class="preview">保存内容</buttondiv>
>

script>
import VueUeditorWrap from 'vue-ueditor-wrap' // ES6 Module
export default {
  name: HelloWorld,components: {
    VueUeditorWrap
  },data () {
    return {
      msg: 请输入内容 编辑器不自动被内容撑高
        autoHeightEnabled: true 初始容器高度
        initialFrameHeight: 240false 初始容器宽度
        initialFrameWidth: 100%''
      }
    }
  },mounted () {

  },methods: {
    showData () {
      console.log(this.msg)
    }
  }
}
>

详细的配置可参考UEditor富文本编辑器官网。

参考地址

相关文章

https://segmentfault.com/a/1190000022018995 https://www....
ES6 (ECMAScript 6)中的模块是一个包含 JavaScript 代码的...
from https://mp.weixin.qq.com/s/-rc1lYYlsfx-wR4mQmIIQQ V...
D:\Temp&gt;npm init vite@latest vue3study --temp...
文章浏览阅读1.2k次。最近自己从零撸起的甘特图组件需要子组...
文章浏览阅读3.3k次,点赞3次,收藏16次。静默打印是什么?简...