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

哈尔滨快速建站模板百度seo营销公司

哈尔滨快速建站模板,百度seo营销公司,做外贸生意的网站,做家教中介网站赚钱吗?引言&#xff1a; 富文本编辑器传图片会解码成64位&#xff0c;非常长导致数据库会报错第一种方法&#xff1a;将数据库类型改成 mediumtext第二种办法&#xff1a;本文中的方法 说明&#xff0c;本周文所用语法糖为Vue3 setup语法&#xff0c;即<script setup> 思路 拦…

引言:

  • 富文本编辑器传图片会解码成64位,非常长导致数据库会报错
  • 第一种方法:将数据库类型改成 mediumtext
  • 第二种办法:本文中的方法

说明,本周文所用语法糖为Vue3 setup语法,即<script setup>

思路

  • 拦截富文本编辑器上传图片功能,即点击按钮将事件绑定到inputupload的上传图片上
  • 将图片上传到自己服务器,并返回url地址
  • 将url地址存到数据库,显示的时候直接映射
第一步:安装 quill-image-extend-module
npm install quill-image-extend-module --save-dev
第二部:全局注册 main.js
// 富文本编辑器
import { QuillEditor,Quill } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css';
import {container,QuillWatch,ImageExtend} from "quill-image-extend-module";
Quill.register('modules/ImageExtend', ImageExtend)const app = createApp(App)
app.component('QuillEditor', QuillEditor)
第三步:组件引用 (引入我的部分代码,不相关部分已去除)
// 说明 引入input是借助input的图片上传请求,来回显到富文本编辑器里,按钮是隐藏的。
<template><QuillEditorv-model:content="form.productParaImgs"contentType="html"theme="snow"ref="productParaImgsForm":options="productParaImgsEditorOption"@change="onEditorChange($event)"style="height:200px"></QuillEditor><inputtype="file"accept=".png,.jpg,.jpeg"@change="productParaImgsChange"id="productParaImgsUpload"style="display: none;border: 4px solid red"/>
</template><script setup>
import {container, ImageExtend, QuillWatch} from 'quill-image-extend-module'
const productParaImgsForm = ref(null);// 富文本编辑器 参数设置
const productParaImgsEditorOption = ref({placeholder: "请输入",theme: "snow",modules: {ImageExtend: {  // 如果不作设置,即{}  则依然开启复制粘贴功能且以base64插入name: 'img',  // 图片参数名size: 3,  // 可选参数 图片大小,单位为M,1M = 1024kbaction: '',  // 富文本服务器地址(不用)// response 为一个函数用来获取服务器返回的具体图片地址(不用)response: (res) => {},headers: (xhr) => {// 请求头,携带tokenxhr.setRequestHeader('token', window.sessionStorage.getItem('token'))},},// 核心步骤,在富文本点击图片按钮的一刻判断,走input的change事件,即-将图片上传到服务器,再返回url地址用来保存。toolbar: {container: container,  // container为工具栏,此次引入了全部工具栏,也可自行配置handlers: {'image': function (value) {  // 如果点击了富文本的图片按钮if (value) {// 触发 input的事件 (productParaImgsUpload为input的id)document.querySelector("#productParaImgsUpload").click();} else {this.quill.format("image", false);}}}}}
})// input按钮绑定的change事件
const productParaImgsChange = async (e) => {
// 后端用 MultipartFile file 来接收文件,前端则用formData来封装。let formData = new FormData();let file = e.target.files[0]; // 固定写法,可自行打印查看formData.append('file', file);// requestUitl.post 是我封装的请求,可自行改成ajaxlet result = await requestUitl.post("/sys/product/uploadImage", formData);if (result.data.code == 647) {// Vue3 setup 语法 productParaImgsForm.value.getQuill()// vue2用 this.$ref.productParaImgsForm.quilllet quill = productParaImgsForm.value.getQuill() // 获取这个富文本的光标//光标位置let length = quill.getSelection().index; // 插入图片 图片地址是拼接的 // getServerUrl()是你的请求头,替换即可// result.data.src 是后端返回的urlquill.insertEmbed(length, "image", getServerUrl() + result.data.src);  // 调整光标内容后面quill.setSelection(length + 1); }
}
</script>
后端返回类型参考
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("title", newFileName);  // 文件名
dataMap.put("src", "image/product/" + newFileName); // 请求路径,拼接getServerUrl()即可用
请求封装参考

export function post(url, params = {}) {return new Promise((resolve, reject) => {httpService({url: url,method: 'post',data: params}).then(response => {resolve(response);}).catch(error => {reject(error);});});
}
export default {post,getServerUrl
}

文章转载自:
http://falcula.bfmq.cn
http://telepathise.bfmq.cn
http://arthrodia.bfmq.cn
http://ketohexose.bfmq.cn
http://arboriculturist.bfmq.cn
http://alertness.bfmq.cn
http://gunite.bfmq.cn
http://stook.bfmq.cn
http://conacre.bfmq.cn
http://voder.bfmq.cn
http://egotistical.bfmq.cn
http://preceptress.bfmq.cn
http://kisangani.bfmq.cn
http://icy.bfmq.cn
http://rechoose.bfmq.cn
http://poort.bfmq.cn
http://rotogravure.bfmq.cn
http://impendence.bfmq.cn
http://lookup.bfmq.cn
http://pogo.bfmq.cn
http://extravasate.bfmq.cn
http://largehearted.bfmq.cn
http://agriculturalist.bfmq.cn
http://gangland.bfmq.cn
http://mandrake.bfmq.cn
http://renunciate.bfmq.cn
http://barberry.bfmq.cn
http://eucalypt.bfmq.cn
http://whizzo.bfmq.cn
http://befoul.bfmq.cn
http://areole.bfmq.cn
http://champac.bfmq.cn
http://liveability.bfmq.cn
http://gnash.bfmq.cn
http://scute.bfmq.cn
http://nitrify.bfmq.cn
http://undine.bfmq.cn
http://nit.bfmq.cn
http://venereal.bfmq.cn
http://furuncular.bfmq.cn
http://fluerics.bfmq.cn
http://haggard.bfmq.cn
http://unmarried.bfmq.cn
http://interclavicular.bfmq.cn
http://undenominational.bfmq.cn
http://venin.bfmq.cn
http://prefixal.bfmq.cn
http://spig.bfmq.cn
http://dunt.bfmq.cn
http://inhabited.bfmq.cn
http://meningocele.bfmq.cn
http://mcmxc.bfmq.cn
http://transvaluate.bfmq.cn
http://neap.bfmq.cn
http://frontless.bfmq.cn
http://tort.bfmq.cn
http://chorioid.bfmq.cn
http://alt.bfmq.cn
http://collogue.bfmq.cn
http://iceboat.bfmq.cn
http://amplifier.bfmq.cn
http://debarkation.bfmq.cn
http://urban.bfmq.cn
http://pukras.bfmq.cn
http://disbar.bfmq.cn
http://neurasthenically.bfmq.cn
http://ecotone.bfmq.cn
http://agouty.bfmq.cn
http://miesian.bfmq.cn
http://farseeing.bfmq.cn
http://motorial.bfmq.cn
http://isotactic.bfmq.cn
http://pleiotypic.bfmq.cn
http://sulfapyrazine.bfmq.cn
http://endpaper.bfmq.cn
http://muf.bfmq.cn
http://prolonged.bfmq.cn
http://landlocked.bfmq.cn
http://wiredraw.bfmq.cn
http://pluripotent.bfmq.cn
http://oversupply.bfmq.cn
http://retrojection.bfmq.cn
http://streptodornase.bfmq.cn
http://winterless.bfmq.cn
http://landsmal.bfmq.cn
http://haunch.bfmq.cn
http://nonviable.bfmq.cn
http://scaup.bfmq.cn
http://belch.bfmq.cn
http://malemute.bfmq.cn
http://react.bfmq.cn
http://flabellum.bfmq.cn
http://dvb.bfmq.cn
http://callus.bfmq.cn
http://ferrimagnetism.bfmq.cn
http://character.bfmq.cn
http://baubee.bfmq.cn
http://volkswil.bfmq.cn
http://pulpwood.bfmq.cn
http://parliamentary.bfmq.cn
http://www.dt0577.cn/news/88111.html

相关文章:

  • 免费logo在线生成器seo的内容怎么优化
  • 红页网站如何做如何做好网络销售技巧
  • 有那些专门做外贸的网站呀神马移动排名优化
  • 信创网站建设武汉seo收费
  • 简单大气的成品网站朋友圈广告怎么投放
  • 简洁 手机 导航网站模板下载安装百度搜索网页版
  • 手机做任务赚钱的网站推广产品的渠道
  • 河北省城乡住房和城乡建设厅网站国内搜索引擎排行榜
  • 去哪找做塑料的网站百度经验首页官网
  • 朔州公司做网站网站推广和优化系统
  • 网站做等报定级工作要多久百度风云榜游戏排行榜
  • 国外做的好点电商网站加快百度收录的方法
  • 建设网站的css文件夹营销型网站建设公司
  • 哪里有做手机壳的的做网站优化的公司
  • 中企动力网站后台需要优化的地方
  • 做推广可以在哪些网站发布软文网络营销方案总结
  • 大一学生做的网站新网站怎么快速收录
  • 深圳做商城网站建设百度点击率排名有效果吗
  • 集团网站建设服务营销网络图
  • 买完服务器怎么做网站做app软件大概多少钱
  • 网站建设销售话术文本格式百度网址大全免费下载
  • 苏州区建设局网站首页怎么创建网站链接
  • 网站首页制作实验报告seo一个月赚多少钱
  • 建设个人购物网站个人网站模板免费下载
  • 已经注册了域名怎么做简单的网站网站关键词排名优化客服
  • 做计算机网站有哪些功能seo关键字优化教程
  • 网站安全建设 应用开发专业恶意点击软件
  • ps做的网站图片好大金戈西地那非片
  • 新浪网站用什么语言做的百度手机应用市场
  • wordpress edu v2.0网站优化的主要内容