vue+element upload上传带参数的方法
发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,今天小编给大家分享一下vue+element upload上传带参数的方法的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后
千家信息网最后更新 2025年11月07日vue+element upload上传带参数的方法
今天小编给大家分享一下vue+element upload上传带参数的方法的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。
element upload上传带参数
保存
选取文件
data里面参数
uploadData:null,
methods里面
action(){ return this.portC+"uplodResultsScore" }, //上传 submitUpload() { this.$refs.upload.submit(); }, handleRemove(file, fileList) { console.log(file, fileList); }, handlePreview(file) { console.log(file); }, beforeUpload (file) { this.uploadData = {dstype:this.proType,name:this.mobanname,dsmark:this.value5,}; console.log(this.uploadData) let promise = new Promise((resolve) => { this.$nextTick(function () { resolve(true); }); }); return promise; //通过返回一个promis对象解决 }, //上传成功钩子 successResave(response, file, fileList){ console.log(response) if(response.code==10001){ alert("保存成功") this.proType=""; this.mobanname=""; this.value5=""; this.$router.push("/moban") } }, //失败钩子 error(response, file, fileList){ console.log(response) }, //选择家化实效 selectType(val){ console.log(val) if(val==1){ this.$router.push("/new") }else{ this.$router.push("/new1") } },效果图
element上传函数带参数,自定义传参
下面这是标签
可以看出来 :
http-request="(params) =>beforeMasterPictureUpload(params,'ruleForm',fileList0)"
http-request 传递参数的方法 是可以这样写的,其他方法一样,但是如果写错少些可能会导致覆盖原来的方法。
下面是JS 接受方法 同样 我们拿 http-request 这个方法做例子
beforeMasterPictureUpload(params, fromData, prop) { console.log('----aaaa', this.fileList); console.log('file', params, fromData, prop);}大家可以输出看看结果 是否有拿到你上面传递过来的字符串或者是值
我将源码放上
HTML标签
JS语句
// 主图上传之前 beforeAvatarUpload(file) { console.log('主图上传之前:', file) const idJPG = file.type === "image/jpeg" || "image/gif" || "image/png" || "image/bmp"; if (!idJPG) { this.$message.error( '123123' ); } return idJPG; }, // 图片触发 onChangeMaster(file, fileList, fromData, prop) { // fileList 当前上传框的数据 switch (prop) { case 'fileList0': { this.hideUpload0 = fileList.length >= this.limitCount; } break; case 'fileList1': { this.hideUpload1 = fileList.length >= this.limitCount; } break; case 'fileList2': { this.hideUpload2 = fileList.length >= this.limitCount; } break; case 'fileList3': { this.hideUpload3 = fileList.length >= this.limitCount; } break; case 'fileList4': { this.hideUpload4 = fileList.length >= this.limitCount; } break; case 'fileList5': { this.hideUpload6 = fileList.length >= this.limitCount; } break; default: break; } console.log('判断一次', file, fileList, this.fileList0) if (this.inde > 0) { return } else { //let existFile = fileList.slice(0, fileList.length - 1).find(f => f.name === file.name) //if (existFile) { // this.inde++ // console.log(existFile) // this.$message.error( // '图片重复' + existFile.name // ); // // fileList.pop() // } this[prop] = fileList } }, // 图片个数超出限制 OnExceed(file, fileList) { this.$message.error( '每个选项最多上传5张', "error" ); }, handleRemove(params, fileList, prop, item) { prop.forEach((obj, index) => { console.log(index, obj) if (params.uid == obj.uid) { prop.splice(index, 1) } }) console.log('删除后的数组', prop); setTimeout(() => { switch (item) { case 'fileList0': { this.hideUpload0 = prop.length >= this.limitCount; } break; case 'fileList1': { this.hideUpload1 = prop.length >= this.limitCount; } break; case 'fileList2': { this.hideUpload2 = prop.length >= this.limitCount; } break; case 'fileList3': { this.hideUpload3 = prop.length >= this.limitCount; } break; case 'fileList4': { this.hideUpload4 = prop.length >= this.limitCount; } break; case 'fileList5': { this.hideUpload6 = prop.length >= this.limitCount; } break; default: break; } console.log(prop.length >= this.limitCount) }, 1000) // this.fileList = []; this.dialogImageUrl = ''; }, handlePictureCardPreview(file, fromData, prop) { console.log(file, fromData, prop) this.dialogImageUrl = file.url; this.dialogVisible = true; }, beforeMasterPictureUpload(params, fromData, prop) { console.log('----aaaa', this.fileList); console.log('file', params, fromData, prop); },这是需求案列

以上就是"vue+element upload上传带参数的方法"这篇文章的所有内容,感谢各位的阅读!相信大家阅读完这篇文章都有很大的收获,小编每天都会为大家更新不同的知识,如果还想学习更多的知识,请关注行业资讯频道。
方法
参数
知识
篇文章
图片
成功
内容
文件
标签
这是
钩子
不同
很大
个数
例子
函数
大部分
字符
字符串
实效
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
观察者模式 数据库
数据库关系模型把世界
计算机网络技术试讲15分钟
华为云怎么购买软件开发平台
软件开发线上培训
数据库er图能闭环吗
把登录注册信息存到数据库
计算机网络技术教程ppt
edge 代理服务器
工业互联网与方正科技
唯一服务器扩容纪念价格
软件开发什么项目挣钱
如何连接生产数据库
迅付宝网络技术有限公司
智能车牌识别管理系统数据库恢复
华为云服务器远程管理口
数据库sql语句去空格
广州销售软件开发联系人
崇明区工商软件开发质量保障
如何入侵网站数据库
修改linux数据库编码
数据库drip
数据库来自同一数据源
网络安全法主要法律
网络安全视频宣传的设计方案
什么服务器能覆盖城镇
崇明区个人数据库服务价钱
开源的文件管理服务器
山西在线网络技术开发项目
数据库原理三级项目指导