首页 > 其他分享 >wangEditor富文本

wangEditor富文本

时间:2023-07-06 17:00:12浏览次数:29  
标签:文本 return wangEditor content editor import null

1、富文本组件

<template>
    <div>
        <Toolbar
            style="border: 1px solid #ccc; border-bottom: 0"
            :editor="editor"
            :defaultConfig="toolbarConfig"
            :mode="mode"
        />
        <Editor
            style="height: 400px; overflow-y: hidden;border: 1px solid #ccc"
            v-model="content"
            :defaultConfig="editorConfig"
            :mode="mode"
            @onCreated="onCreated"
        />
    </div>
</template>

<script>
import {Editor, Toolbar} from '@wangeditor/editor-for-vue'
import {getEditorConfig} from "@/assets/js/editorConfig";
export default {
    name: "wangEditor",
    components: {Editor, Toolbar},
    props: {
        value: {
            type: String,
            default: ''
        }
    },
    watch: {
        value: {
            handler(newValue, oldValue) {
                this.content = newValue
            }
        }
    },
    data() {
        return {
            editor: null,
            toolbarConfig: {},
            editorConfig: getEditorConfig(),
            mode: 'default', // or 'simple',
            content: this.value
        }
    },
    methods: {
        onCreated(editor) {
            this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
        },
        getValue() {
            if (this.editor.getText().trim()) {
                return this.content
            } else {
                return null
            }
        }
    },
    beforeDestroy() {
        const editor = this.editor
        if (editor == null) return
        editor.destroy() // 组件销毁时,及时销毁编辑器
    }
}
</script>

<style src="@wangeditor/editor/dist/css/style.css"></style>

2、使用

import wangEditor from "@/components/wangEditor.vue";
components: {
     wangEditor
},
<wangEditor ref="editor" :value="form.describe"></wangEditor>

3、提交时候获取值

this.form.noticeContent = this.$refs.editor.getValue()

标签:文本,return,wangEditor,content,editor,import,null
From: https://www.cnblogs.com/zhaoliang1997/p/17287079.html

相关文章

  • java实现文本转语音(即语音朗读)
    java实现文本转语音(即语音朗读)1.方式一:使用jacob离线语音合成1.下载jacob-1.18.zip链接:https://pan.baidu.com/s/1-zYB9I4VF5cPuj3ok1WLyg提取码:7t1g2.将jacob-1.18-x64.dll拷贝到jdk的bin目录或windows/SysWOW64目录中3.添加需要的依赖<!--https://mvnrepository.com/a......
  • 2023-07-06 uview-ui组件u-checkbox设置label-disabled无效==》点击文本仍旧触发check
    解决方案:既然无效,那就给checkbox包裹的文本绑定一个点击事件,该点击事件使用.stop来阻止事件冒泡,这样点击文本就不会触发checkbox的change了,可以参考一下代码:<u-checkbox><[email protected]="stopBack"></View></u-checkbox>关键点:@click.stop注:改问题出自uview-ui1.......
  • SQL server字符串截取——根据指定符号截取字符串/截取文本
     ##-对字符串进行简单的处理,调用单个函数1.情况1:取字符串前X位用函数LEFT()SELECTLEFT([字段名],6)FROMDUAL;2.情况2:取字符串后X位用函数RIGHT()SELECTRIGHT([字段名],6)FROMDUAL;3.情况3:取字符串中间位数,例如,取身份证号中的出生年月用函数SUBSTRING()......
  • textView调用setText但是显示的文本没变化
    甚至其他的textView都可以修改,只有他不行,我也不知道怎么点出了一个viewbinding的文件中的相同id,发现有一个相同id,但是并不是我要修改的那个textView是final,于是我把我要修改textView的id修改之后,就可以了估计是id重复导致的冲突吧,但是我在查找id重复的资料,似乎都说在不同文件......
  • API6中JS UI实现富文本组件居右显示
    ​ 【关键字】RichText、富文本组件、API6、JS UI、居右显示 【关键代码如下】index.hml<divclass="container"><divclass="top"><richtext@start="onLoadStart"@complete="onLoadEnd"class="rich">{{con......
  • css文本&布局属性
    1.writing-mode(协作模式):块内容(段落)在页面的流程方式  horizontal-tb(默认):水平内容,从上到下  vertical-lr:垂直内容,从左到右  vertical-rl:垂直内容,从右到左2.direction(方向):内联内容(字符)如何在屏幕上流动  ltr(默认):从左到右  rtl:右到左3.flex(弹性盒子)-物理属......
  • excle解决文本匹配大量关键字
    SubkeyWordFilter()Dimsht1AsWorksheet,sht2AsWorksheet,sht3AsWorksheet,maxRow1AsInteger,maxRow2AsInteger,maxRow3AsInteger,userNameAsString,iAsInteger,jAsInteger,keyWordAsString,kAsIntegerSetsht1=ThisWorkbook.Sheets(&q......
  • 文本可以包含空格,但是不能全部是空格的正则表达式怎么写?
    正则表达式^(?=.*\S).+$单字符解释.默认匹配除换行符之外的任何单个字符。例如,.n/会匹配nay,anappleisonthetree"中的an'和on'但是不会匹配'nay'*匹配前一个表达式0次或多次。\S除空格(换行符、制表符、空格)外的任何内容。exp1(?=exp2)查找后面跟着exp2的ex......
  • Python | import mmap模块详解(处理大文本)
    如果现在有一个需求,我们需要处理一个20G的大文件,我们会怎么处理呢?思考下,我们需要怎么实现这个功能。我们可能会这么实现:defget_datas():source_text_path="路径"withopen(source_text_path,'rb')asf:data=f.readlines()yielddataif__na......
  • office pdf 文本提取
    usingSystem;usingSystem.Diagnostics;usingSystem.Runtime.InteropServices;usingSystem.Text;namespaceIFilter{[Flags]publicenumIFILTER_INIT:uint{NONE=0,CANON_PARAGRAPHS=1,HARD_LINE_BREAKS=2,CANON_HYPHENS=4,CANON_SPA......