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

怎样把网站推广出去php企业网站开发pdf

怎样把网站推广出去,php企业网站开发pdf,河南建设厅网站查证,互联网广告投放代理公司要在 Element UI 的拖拽上传组件中实现 Ctrl V 图片上传功能#xff0c;可以通过监听键盘事件来捕获粘贴操作#xff0c;并将粘贴的图片数据上传到服务器。 版本V1#xff0c;实现获取粘贴板中的文件 注意#xff0c;本案例需要再你已经安装了Element UI并在项目中正确配…要在 Element UI 的拖拽上传组件中实现 Ctrl V 图片上传功能可以通过监听键盘事件来捕获粘贴操作并将粘贴的图片数据上传到服务器。 版本V1实现获取粘贴板中的文件 注意本案例需要再你已经安装了Element UI并在项目中正确配置的情况下进行第一个版本仅适合上传jpeg和png的图片 创建拖拽上传组件 假设你已经有一个基本的拖拽上传组件我们可以在此基础上添加 Ctrl V 功能。 监听粘贴事件 我们需要在页面中监听 paste 事件当用户按下 Ctrl V 时捕获粘贴板中的图片数据。 处理粘贴事件 在捕获到图片数据后将其转换为 File 对象并调用上传方法。 代码如下 templatedivel-uploaddragactionhttps://jsonplaceholder.typicode.com/posts/:on-previewhandlePreview:on-removehandleRemove:before-uploadbeforeUploadmultiplerefuploadi classel-icon-upload/idiv classel-upload__text将文件拖到此处或em点击上传/em/divdiv classel-upload__tip slottip只能上传jpg/png文件且不超过500kb/div/el-upload/div /templatescript import { Upload } from element-ui;export default {name: DragUpload,methods: {handlePaste(event) {// 捕获粘贴事件const items event.clipboardData.items;for (let i 0; i items.length; i) {if (items[i].type.indexOf(image) ! -1) {// 获取图片文件const file items[i].getAsFile();this.handleFile(file);break;}}},handleFile(file) {// 将文件添加到上传队列this.$refs.upload.handleStart(file);this.$refs.upload.submit();},handlePreview(file) {console.log(Preview:, file);},handleRemove(file, fileList) {console.log(Remove:, file, fileList);},beforeUpload(file) {const isJPGorPNG file.type image/jpeg || file.type image/png;const isLt500K file.size / 1024 500;if (!isJPGorPNG) {this.$message.error(只能上传 JPG/PNG 格式的图片!);}if (!isLt500K) {this.$message.error(图片大小不能超过 500KB!);}return isJPGorPNG isLt500K;}},mounted() {// 监听粘贴事件document.addEventListener(paste, this.handlePaste);},beforeDestroy() {// 移除粘贴事件监听document.removeEventListener(paste, this.handlePaste);} }; /scriptHTML部分使用 el-upload 组件创建一个拖拽上传区域。JavaScript部分 handlePaste 方法捕获粘贴事件检查粘贴板中的数据是否为图片文件如果是则调用 handleFile 方法。handleFile 方法将图片文件添加到上传队列并提交上传。mounted 生命周期钩子添加粘贴事件监听器。beforeDestroy 生命周期钩子移除粘贴事件监听器防止内存泄漏。 随便截图一张我们这个时候ctrl v 就可以发现他可以获取我们粘贴板中的文件。 我们到这一步发现图片网页是获取到。这个时候你在跟着你的业务传递相关参数这第V1版本就可以用了。 第二版本V2,可以直接在粘贴的过程在下面以压缩图片的形式展示图片 templatedivel-uploaddrag:actionuploadFileUrl:on-previewhandlePreview:on-removehandleRemove:before-uploadbeforeUpload:on-successhandleSuccessmultiplerefupload:file-listfileListi classel-icon-upload/idiv classel-upload__text将文件拖到此处或em点击上传/em/divdiv classel-upload__tip slottip只能上传jpg/png文件且不超过500kb/div/el-upload!-- 显示上传后的文件 --div v-for(file, index) in fileList :keyindex classuploaded-filediv v-ifisImage(file.name)img :srcfile.url altUploaded Image classuploaded-image /el-button typetext clickremoveFile(index)移除/el-button/divdiv v-elsespan{{ file.name }}/spanel-button typetext clickremoveFile(index)移除/el-button/div/div/div /templatescript import { Upload } from element-ui;export default {name: DragUpload,data() {return {fileList: []};},methods: {handlePaste(event) {const items event.clipboardData.items;for (let i 0; i items.length; i) {if (items[i].type.indexOf(image) ! -1) {const file items[i].getAsFile();this.handleFile(file);break;}}},handleFile(file) {const reader new FileReader();reader.onload (e) {this.fileList.push({name: file.name,url: e.target.result});};reader.readAsDataURL(file);this.$refs.upload.handleStart(file);this.$refs.upload.submit();},handlePreview(file) {console.log(Preview:, file);},handleRemove(file, fileList) {this.fileList fileList;},beforeUpload(file) {const isJPGorPNG file.type image/jpeg || file.type image/png;const isLt500K file.size / 1024 500;if (!isJPGorPNG) {this.$message.error(只能上传 JPG/PNG 格式的图片!);}if (!isLt500K) {this.$message.error(图片大小不能超过 500KB!);}return isJPGorPNG isLt500K;},handleSuccess(response, file, fileList) {// 更新 fileListthis.fileList fileList.map(f ({name: f.name,url: f.url || f.response.url // 假设服务器返回的响应中有 url 字段}));},removeFile(index) {this.fileList.splice(index, 1);},isImage(fileName) {return fileName.toLowerCase().endsWith(.jpg) || fileName.toLowerCase().endsWith(.png);}},mounted() {document.addEventListener(paste, this.handlePaste);},beforeDestroy() {document.removeEventListener(paste, this.handlePaste);} }; /scriptstyle scoped .uploaded-file {margin-top: 10px;display: flex;align-items: center; }.uploaded-image {max-width: 100px;max-height: 100px;margin-right: 10px; } /style如图所示。Ctrl V就实现到了这一步。这里有问题那就是你看一下点击上传后的图片是否会显示出来呢
http://www.hkea.cn/news/14275752/

相关文章:

  • 门户网站建设方案免费的个人网站平台
  • 沧州网站群现在什么网页游戏最好玩最火
  • 文明网站的建设与管理的思考企业网站建设方案优化
  • 网站建设济南云畅网络技术有限公司ppt汇报模板下载
  • 西宁做网站_君博先进wordpress改登录地址
  • 如何进入网站那个网站seo做的好的
  • 上海网站建设的网wap网站 链接微信
  • Wordpress网站开发收费长春火车站需要核酸检测报告吗
  • 网站三要素怎么做深圳开发公司网站
  • 新手做网站做什么样的做网站技术人员
  • 网络运维和网站开发玩具 网站模板
  • 广东省住房与城乡建设部网站照片书那个网站做的好
  • 网站建设开票的税收分类帮做非法网站
  • 北京有什么网上推广的网站吗平面设计师招聘
  • 建设校园网站公司网站维护的方式有哪几种
  • 网站开发非常之旅网站建设对企业重要性
  • wordpress建站教程道一在中国如何申请域名
  • 制作一个学校门户网站wordpress博客主题zip
  • 网站建设资讯站网页素材网
  • 网站调用优酷视频去除广告的方法新乡网站建设报价
  • 重庆门户网站排名注册网站免费注册ins
  • 通辽网站建设公司个人网页设计要素
  • 视频网站能备案吗站长申论
  • html购物网站代码58企业网站如何做
  • 网页升级访问新域名久久seo正规吗
  • 无为网站定制林州网站建设哪家便宜
  • 重庆江北网站建设公司西安网络建设公司
  • 学院门户网站建设必要性手机app与电脑网站的区别
  • 深圳专业网站制作技术百度统计会对原网站产生影响吗
  • 永康新站优化软件免费下载的网站大全