当前位置: 首页 > news >正文

wangeditor编辑器配置

vue项目中使用编辑器,轻量,操作栏选取自己需要的

官网地址:用于 Vue React | wangEditor

使用在vue项目中引入
 

npm install @wangeditor/editor --savenpm install @wangeditor/editor-for-vue --save

封装成组件使用

<template><div style="border: 1px solid #ccc; margin:0 auto;"><Toolbarstyle="border-bottom: 1px solid #ccc;":editor="editor":defaultConfig="toolbarConfig":mode="mode"/><Editorstyle="height: 500px; overflow-y: hidden;"v-model="html":defaultConfig="editorConfig":mode="mode"@onCreated="onCreated"@onChange="onChange"/></div>
</template>
<script>import Vue from 'vue'import { Editor, Toolbar } from '@wangeditor/editor-for-vue'export default Vue.extend({components: { Editor, Toolbar },props: {value: { type: String, required: true },},data() {return {editor: null,html: '',toolbarConfig: { excludeKeys:["blockquote","header1","header2","header3","headerSelect", "fontFamily","code","clearStyle","todo", "emotion","insertLink","insertImage", "insertTable","group-video","codeBlock","redo","headerSelect","insertVideo",]},editorConfig: { placeholder: '请输入内容...' ,MENU_CONF: {uploadImage: {// 配置上传图片customUpload: this.update},},},mode: 'simple', // or 'default'}},created(){    },methods: {onCreated(editor) { this.editor = Object.seal(editor) },onChange(editor) {this.$emit('change', editor.getHtml());},getEditorText() {const editor = this.editor;if (editor == null) return;},        update(files,insertFn){//图片上传var formData = new FormData();formData.append('file', files);//根据后台提供的图片上传接口,进行接口配置和上传this.apiSever.post(this.URl.UPLOAD,formData, res => {insertFn(res.data.url);})},},mounted() {this.$nextTick(() => {this.html = this.value})},beforeDestroy() {const editor = this.editorif (editor == null) returneditor.destroy() }
})
</script>
<style src="@wangeditor/editor/dist/css/style.css"></style>

 

http://www.lryc.cn/news/98374.html

相关文章:

  • Sqlite使用WAL模式指南
  • 一套高质量可靠的 React Hooks 库
  • 集合---list接口及实现类
  • JVM简述
  • 7.25训练总结
  • java注解@FeignClient修饰的类路径不在spring boot入口类所在的包下,有哪几种处理方式?
  • 神经网络随记-参数矩阵、剪枝、模型压缩、大小匹配、、
  • 4、Kubernetes 集群 YAML 文件详解
  • leetcode93. 复原 IP 地址(java)
  • 极光Java 版本服务器端实现别名消息推送
  • 【Lua学习笔记】Lua进阶——Table(4)继承,封装,多态
  • 安全性证明(四)Practical Identity-Based Encryption Without Random Oracles
  • Linux中常用的指令
  • 【java】【面对对象高级4】内部类、枚举、泛型
  • Python的用处到底是什么?(三)
  • 【Nodejs】Express基本使用
  • k8s集群安装v1.20.9
  • Staples Drop Ship EDI 需求分析
  • 模型调参及优化
  • 多数据源数据转换和同步的ETL工具推荐
  • 配置 gitlab https 访问
  • Kepware Modbus驱动简介
  • 从零开始学习CTF——CTF是什么
  • 为Android构建现代应用——主体结构
  • 【shell脚本】shell脚本之日志切割(进阶实战三)
  • VMLogin和虚拟机里的浏览器有什么区别?
  • unimrcp server的session资源分配与回收
  • 【图论】三种中心性 —— 特征向量、katz 和 PageRank
  • [sqoop]将hive查询后的数据导入到MySQL
  • Linux df、du命令