vite+vue3使用UEditorPlus

  • 什么是UEditorPlus
    • 功能亮点
  • 前端安装
    • 安装vue-ueditor-wrap@3.x
    • 下载 UEditorPlus
    • 在main.js注册组件
    • v-model 绑定数据
  • 后端配置
  • 效果

百度富文本编辑器是目前所有编辑器中功能最丰富的,但长时间不进行维护了。
之前写了一篇使用UEditor的教程,最近发现一个UEditorPlus,总结一下如何使用

什么是UEditorPlus

基于 UEditor 二次开发的富文本编辑器,让UEditor重新焕发活力
文档:https://open-doc.modstart.com/ueditor-plus/
仓库:https://gitee.com/modstart-lib/ueditor-plus

功能亮点

  • 全新的UI外观,使用字体图标替换原有图片图标
  • 移除过时、无用的插件支持,不断完善使用体验
  • 图片、文件、视频上传配置化定制增强
  • 演示界面重构,右上角可直接查看当前演示界面代码
  • 兼容现有UEditor,实现无缝切换

前端安装

安装vue-ueditor-wrap@3.x

vue-ueditor-wrap@3.x:一个“包装”了 UEditor 的 Vue 组件,支持通过 v-model 来绑定富文本编辑器的内容,让 UEditor 的使用简单到像 Input 框一样。省去了初始化 UEditor、手动调用 getContent,setContent 等繁琐的步骤。

// vue-ueditor-wrap v3 仅支持 Vue 3
npm i vue-ueditor-wrap@3.x -S
// or
yarn add vue-ueditor-wrap@3.x

下载 UEditorPlus

下载 仓库 的dist文件夹,并放到public下,重命名为UEditorPlus

在main.js注册组件

// main.js
import { createApp } from 'vue';
import VueUeditorWrap from 'vue-ueditor-wrap';
import App from './App.vue';createApp(App).use(VueUeditorWrap).mount('#app');

v-model 绑定数据

<template><div class="content"><vue-ueditor-wrap v-model="content" editor-id="editor" :config="editorConfig":editorDependencies="['ueditor.config.js', 'ueditor.all.js']" style="height:500px;" /></div>
</template>
<script setup>
import { ref } from 'vue';
let content = ref('<p>Hello UEditorPlus</p>')
let editorConfig = {serverUrl: '后端服务,下面后端的上传接口',// 配置UEditorPlus的惊天资源UEDITOR_HOME_URL: '/UEditorPlus/'
}
</script>

后端配置

1、找一个文件夹新建config.json,写入以下代码

{"imageActionName": "uploadimage","imageFieldName": "upfile","imageMaxSize": 2048000,"imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"],"imageCompressEnable": true,"imageCompressBorder": 1600,"imageInsertAlign": "none","imageUrlPrefix": "","imagePathFormat": "/uploads/{yyyy}{mm}{dd}/{time}{rand:6}","videoActionName": "uploadvideo","videoFieldName": "upfile","videoPathFormat": "/uploads/{yyyy}{mm}{dd}/{time}{rand:6}","videoUrlPrefix": "","videoMaxSize": 102400000,"videoAllowFiles": [".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"],"fileActionName": "uploadfile","fileFieldName": "upfile","filePathFormat": "upload/file/{yyyy}{mm}{dd}/{time}{rand:6}","fileMaxSize": 102400000,"fileAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp",".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml", ".crx"]
}

2、写文件上传接口

public function index(){$action = $this->request->param('action');switch($action){case 'config':$result = file_get_contents(ROOT_PATH.'/public/assets/addons/ueditorbjq/config.json');// json文件的路径break;case 'uploadimage':$file = $this->request->file('upfile');if($file){$info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');$res = $info->getInfo();$res['state'] = 'SUCCESS';$res['url'] = '/uploads/'.$info->getSaveName();$result = json_encode($res);}break;case 'uploadvideo':$file = $this->request->file('upfile');if($file){$info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');$res = $info->getInfo();$res['state'] = 'SUCCESS';$res['url'] = '/uploads/'.$info->getSaveName();$result = json_encode($res);}break;case 'uploadfile':$file = $this->request->file('upfile');if($file){$info = $file->move(ROOT_PATH . 'public' . DS . 'uploads' . DS . 'file');$res = $info->getInfo();$res['state'] = 'SUCCESS';$res['url'] = '/uploads/file/'.$info->getSaveName();$result = json_encode($res);}break;default:break;}return $result;}

效果

上传图片视频等可以使用了

vite+vue3使用UEditorPlus ,后端PHP相关推荐

  1. vite+vue3使用ueditor,后端PHP

    vite+vue3使用ueditor,后端PHP 前端 后端 综合所有前端能用的富文本编辑器,功能最好最多的还是百度的富文本编辑器(ueditor) 前端 1.下载ueditor,将其放在public ...

  2. Vite+Vue3+TypeScript

    2021年最新最完整Vite+Vue3+TypeScript基础知识案例<一> 1.学习背景 随着前端web应用的需求不断发展和变化,vue生态圈也紧跟开发者步伐,不断演化.尽管vue2. ...

  3. 如何开发一款基于 Vite+Vue3 的在线Excel表格系统(上)

    今天,葡萄带你了解如何基于Vite+Vue3实现一套纯前端在线表格系统. 在正式开始项目介绍之前,首先咱们首先来介绍一下Vite和Vue3. Vue3 2020年09月18日Vue.js 3.0发布, ...

  4. 基于Vite + Vue3 + NaiveUI + TypeScript的中后台管理模版 — Soybean Admin开源啦

    ???基于Vite + Vue3 + NaiveUI + TypeScript的中后台管理模版 - Soybean Admin开源啦??? 简介 Soybean Admin 是一个基于 Vue3.Vi ...

  5. Vite+Vue3+TypeScript基础知识案例

    Vite+Vue3+TypeScript基础知识案例<一> 1.学习背景 随着前端web应用的需求不断发展和变化,vue生态圈也紧跟开发者步伐,不断演化.尽管vue2.0已经很完善了,很多 ...

  6. Vite(四)后端集成、比较Snowpack、从 v1 迁移、Awesome Vite.js

    Vite(四)后端集成.比较Snowpack.从 v1 迁移.Awesome Vite.js 文章目录 Vite(四)后端集成.比较Snowpack.从 v1 迁移.Awesome Vite.js 1 ...

  7. vite+vue3+ts项目搭建之集成qiankun让其成为子应用模板(vite+vue3+ts+qiankun项目)—新增主应用在线地址可以进入vue2/vue3子应用

    前言 以下操作,是续接之前 第四步 --即:vite+vue3+ts+pinia+element-plus项目已完成搭建好,可以直接业务开发了 主应用技术栈:vue2+webpack+js 集成qia ...

  8. Vite+Vue3+ElementUI-Plus中全局配置中文

    项目环境 Vite Vue3 ElementUI-Plus 按需引用 具体搭建过程可参考我的这篇博客:使用Vite搭建Vue3+ElementUI-Plus项目过程. 设置ElmentUI-Plus中 ...

  9. vite + vue3 + ts集成Cesium

    vite + vue3 + ts集成Cesium 安装cesium:npm i cesium vite-plugin-cesium vite -D 在vite.config.ts中进行相应的cesiu ...

最新文章

  1. 人类首次商业太空行走敲定!马斯克SpaceX宣布新一轮太空旅行计划,美国富豪成回头客...
  2. Runloop底层原理--源码分析
  3. SpringMVC+Hibernate +MySql+ EasyUI实现POI导出Excel(二)
  4. 怎么才能升级成鸿蒙系统,怎么能升级成鸿蒙系统
  5. terminateActivity
  6. contentsize and frame
  7. 导出无法正常启动的VMware虚拟机中的文件
  8. 关于keeplive
  9. 晶振-电路中的心脏起搏器
  10. php 根据ip 扫描端口,域名端口扫描-在线端口检测开放检查-IP端口批量扫描在线工具...
  11. 微软java虚拟机下载_微软Java虚拟机下载-Microsoft VM(Java虚拟机)5.0.3805最新版 - 维维软件园...
  12. Use HAProxy to load balance 300k concurrent tcp socket connections: Port Exhaustion, Keep-alive and
  13. Python教程 - Django
  14. 【多目标进化优化】NSGAII 算法原理与代码实现
  15. GROMACS知识问答
  16. Delphi 获取菜单高度、标题栏高度、边框高度函数GetSystemMetrics
  17. android 登录注册动画,Android开发(14)——动画实战:炫酷登录
  18. 墨画子卿第四章第2节:如意随心
  19. android项目重构经验总结
  20. 推荐一款微信 Markdown 编辑器

热门文章

  1. apache与Subversion
  2. pp什么意思_【问答】pp测试中的“pp”是什么意思啊? - 邦阅网-外贸知识服务平台...
  3. python循环语句
  4. 职场中为什么要每天开例会?
  5. Unity3D大风暴之入门篇(海量教学视频版)
  6. NDIS网络数据监控程序NDISMonitor(2)-----驱动与应用的中间层NdisHook
  7. Stimulsoft.Report 2、 web报表的使用
  8. 影像数据全院连通+集中管理,博为全院级PACS助力桑植县人民医院顺利通过二甲复审
  9. 多核cpu应用场景_多核?高频?不同需求哪种CPU最适合自己呢?
  10. 对于tk.StringVar()理解