可以实现富文本的插件:
vue-quill-editor、editor-for-vue
我们以 editor-for-vue 为例实现:
传送门:wangEditor官网地址
安装:
npm install @wangeditor/editor --save
npm install @wangeditor/editor-for-vue --save
 
具体使用方法:
 引入样式及组件
<template>
    <div style="border: 1px solid #ccc">
      <Toolbar
        style="border-bottom: 1px solid #ccc"
        :editor="editor"
        :defaultConfig="toolbarConfig"
        :mode="mode"
      />
      <Editor
        :disabled="disabled"
        style="height: 500px; overflow-y: hidden;"
        v-model="html"
        :defaultConfig="editorConfig"
        :mode="mode"
        @onCreated="handleCreated"
      />
    </div>
</template>
<script>
import '@wangeditor/editor/dist/css/style.css'
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
export default {
    components: { Editor, Toolbar },
    // props
    data() {
        return {
            isView: true,
            editor: null,
            disabled: true,
            html: '<p>hello</p>',
            toolbarConfig: { },
            editorConfig: { placeholder: '请输入内容...' },
            mode: 'simple', // or 'default'
        }
    },
    methods: {
        handleCreated(editor) {
            this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
            // 实现编辑器的禁用
            if(this.isView){
                this.editor.disable()
            }
        },
    },
    beforeDestroy() {
        const editor = this.editor
        if (editor == null) return
        editor.destroy() // 组件销毁时,及时销毁编辑器
    }
}
</script>
<style>
</style>
 
实现效果:
 














![P8707 [蓝桥杯 2020 省 AB1] 走方格](https://img-blog.csdnimg.cn/direct/fd54e0c9750d4b6f81bf9a5d44e00f1a.png)




