textBox.vue 1.31 KB
<template>
  <div>
    <div id="div-demo"></div>
  </div>
</template>

<script>
import E from 'wangeditor'
export default {
  name: 'textBox',
  data() {
    return {
      editor: '',
      content: '',
      editorOption: {}
    }
  },
  mounted() {
    this.getEdit()
  },
  methods: {
    getEdit() {
      this.editor = new E('#div-demo')
      this.editor.config.uploadImgShowBase64 = true
      this.editor.config.showMenuTooltips = true
      this.editor.config.menuTooltipPosition = 'down'
      this.editor.config.height = 400
      this.editor.config.width = 500
      this.editor.config.uploadVideoServer = '/api/upload-video'
      this.editor.config.excludeMenus = ['code']
      this.editor.config.onchange = html => {
        // console.log(html);
        this.content = html // 绑定当前逐渐地值
        this.$emit('change', this.content) // 将内容同步到父组件中
      }
      this.editor.config.onchangeTimeout = 5000
      this.editor.create()
    },
    setEdit(html) {
      this.$nextTick(() => {
        this.editor.txt.html(html)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
#div-demo {
  margin: 16px 300px 0 0;
}
.el-form .editor {
  margin-top: 20px;
}
.myQuillEditor {
  background-color: #fff;
  height: 200px;
}
</style>
<style>
.w-e-text-container {
  z-index: 1!important;
}
</style>