vue使用富文本

1、安装

cnpm install vue-quill-editor

2、在main.js中引入

// 富文本
import VueQuillEditor from 'vue-quill-editor'
// require styles 引入样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)

3、使用

<template>
	<div>
        <quill-editor 
            v-model="content" 
            ref="myQuillEditor" 
            :options="editorOption" 
            @blur="onEditorBlur($event)" @focus="onEditorFocus($event)"
            @change="onEditorChange($event)">
        </quill-editor>
        <!-- 富文本内容 -->
        <div class="text"></div>
        <button v-on:click="saveHtml">保存</button>
    </div>
</template> 
<script>
    import { quillEditor } from 'vue-quill-editor'
    import $ from 'jquery'//先安装jquery
    export default{
        data(){
            return {
                content:null,
                editorOption:{}
            }
        },
        computed: {
	       editor() {
	            return this.$refs.myQuillEditor.quill;
	        },
	    },
        methods:{
            onEditorBlur(){//失去焦点事件
            },
            onEditorFocus(){//获得焦点事件
            },
            onEditorChange(){//内容改变事件
            	//console.log(this.content)
        		//$('.text').html(this.content)
            },
            saveHtml(event){//点击保存按钮保存
	          alert(this.content);
	        }
        }
    }
</script>    

在这里插入图片描述

相关推荐

  1. vue2使用文本wangeditor

    2024-01-30 20:04:03       61 阅读
  2. vue文本层级高

    2024-01-30 20:04:03       34 阅读
  3. vue 预览v-html 文本里的图片 使用vant

    2024-01-30 20:04:03       42 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-30 20:04:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-30 20:04:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-30 20:04:03       82 阅读
  4. Python语言-面向对象

    2024-01-30 20:04:03       91 阅读

热门阅读

  1. STM32串口IAP

    2024-01-30 20:04:03       58 阅读
  2. 利用qrcode.vue库生成二维码

    2024-01-30 20:04:03       54 阅读
  3. 浅谈MySQL3种日志

    2024-01-30 20:04:03       49 阅读
  4. 数据库(SQL)

    2024-01-30 20:04:03       46 阅读
  5. Dockerfile实践

    2024-01-30 20:04:03       42 阅读
  6. Redis

    Redis

    2024-01-30 20:04:03      54 阅读
  7. 207. 课程表

    2024-01-30 20:04:03       63 阅读
  8. 211. 添加与搜索单词 - 数据结构设计

    2024-01-30 20:04:03       73 阅读
  9. TCP的三次握手和四次挥手

    2024-01-30 20:04:03       58 阅读
  10. 前端面试题-说说你了解的js数据结构?(2024.1.29)

    2024-01-30 20:04:03       54 阅读
  11. 【C++】operator()

    2024-01-30 20:04:03       63 阅读
  12. 【城市大脑】城市数字大脑:智慧城市的新引擎

    2024-01-30 20:04:03       50 阅读