vue3 添加wangEditor富文本框
- 在package.js添加
"@wangeditor/editor": "^5.1.14",
"@wangeditor/editor-for-vue": "^5.1.10",
- 创建组件
<template>
<div style="height: 100%; width: 100%">
<div>
<Toolbar :editor="editorRef" :defaultConfig="toolbarConfig" />
<Editor
:defaultConfig="editorConfig"
v-model="valueHtml"
style="height: 600px; overflow-y: hidden"
@onCreated="handleCreated"
@onChange="handleChange"
@onDestroyed="handleDestroyed"
@onFocus="handleFocus"
@onBlur="handleBlur"
@customAlert="customAlert"
@customPaste="customPaste"
/>
</div>
</div>
</template>
<script setup>
import "@wangeditor/editor/dist/css/style.css";
import {
onBeforeUnmount, ref, shallowRef, onMounted, defineEmits, computed } from "vue";
import {
Editor, Toolbar } from "@wangeditor/editor-for-vue";
import {
getToken } from "@/utils/auth";
import {
ElMessage } from "element-plus";
const props = defineProps({
modelValue: {
type: String,
default: ""
},
isHaveImg: {
type: Boolean,
default: false
}
});
const editorRef = shallowRef();
const valueHtml = ref("");
const baseUrl =