关于富文本插件wangEditor的常规性问题总结

关于富文本插件wangEditor的常规性问题总结

官网地址:https://www.wangeditor.com

1、网页粘贴的内容,样式不全,部分样式被冲掉
	可通过以下两行代码设置 来关闭样式过滤。 		
	editor.config.pasteFilterStyle = false  		
	editor.config.pasteTextHandle = true
2、压缩后的代码回显在富文本框内
editor.txt.html(`<p>${this.modifyThe.blogContent}</p>`)
3.直接上代码
<template>
	//先创建富文本的编辑区域
	<div id="div1" v-model="blogContent"></div>
<template>
<script>
    import VueFroala from 'vue-froala-wysiwyg'; // npm i wangeditor --save	下载引用
	export default {
        data (){
            return {
                blogContent:"",
                editor:null
            }
        },
        mounted(){
            const editor = new e(`#div1`) //创建一个deitor实例并且挂载到div1上
            editor.config.pasteFilterStyle = false   // 粘贴过滤图片样式
            editor.config.pasteTextHandle = true
            // 配置 onchange 回调函数,将数据同步到 vue 中
            editor.config.onchange = (newHtml, a, b) => {
              this.ruleForm.blogContent = newHtml
            }
            editor.config.uploadImgShowBase64 = true
            editor.config.showLinkImg = false
            editor.config.menus = [
              'head', // 标题
              'bold', // 粗体
              'fontSize', // 字号
              'fontName', // 字体
              'italic', // 斜体
              'underline', // 下划线
              'strikeThrough', // 删除线
              'indent', // 缩进
              'lineHeight', // 行高
              'foreColor', // 文字颜色
              'backColor', // 背景色
              'list', // 序列
              'justify', // 对齐
              'quote', // 引用
              'table',//表格
              'splitLine',  //分割
              'image',
              'undo',
              'redo',
              '黑体',
              '仿宋',
              '楷体',
              '标楷体',
              '华文仿宋',
              '华文楷体',
              '宋体',
              '微软雅黑',
              '#0064B9'
            ];
            editor.create() //创建编辑器----切记,创建编辑器一定要放在最后
            this.editor = editor
        },
        beforeDestroy () {
            // 调用销毁 API 对当前编辑器实例进行销毁
            this.editor.destroy()
            this.editor = null
        },
        methods:{
            //富文本内容回显
            this.editor.txt.html(`<p>${this.modifyThe.blogContent}</p>`) 
            this.editor.txt.clear()  // 清空富文本内容
        
        }
    }
</script>

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值