elementui el-upload 在v-for里使用时 如何获取index
<div v-for = 'item in list'>
<div @click="getImageTypeIndex(index)">
<el-upload
class="upload-demo"
drag
:action="uploadUrl"
:headers = "{token : userToken}" //带用户token
:on-success="getImageSuccess" //上传成功
:before-upload="beforeAvatarUpload"
:show-file-list = "false"
:on-error = "getImageError"
>
//若上传失败,可继续拖拽
<div v-show="!item.imageUrl">
<i class="el-icon-upload"></i>
<p class="c8492A6 f14 upload-p">点击或拖拽 上传<span class="cFF8400">图片</span></p>
<p class="c8492A6 f12 upload-p">只能上传 jpg/png 文件,且不超过500kb</p>
</div> //若上传成功,展示图片
<img v-show="item.imageUrl" :src="imgUrl + '?fileId=' + item.imageUrl + '&token=' + userToken" alt="" height="">
</el-upload>
</div>
</div>
// 获取当前index
getImageTypeIndex:function (index) {this.uploadImageType = index //先在data里定义下,此处省略定义},
// 图片上传成功
getImageSuccess:function (res, file) {
this.$message({
message: '上传成功!',
type: 'success'
});
this.list[this.uploadImageIndex].imageUrl = res.data.fileId //我这里是list里有 imageUrl 来存储图片id,展示的地方根据id自己拼url
},
备注:el-upload 的 getImageSuccess 方法 ,暂不支持其他参数,所以为了获取列表的index,可以通过以上方法,在el-upload外层套一个div获取index, 然后再在 getImageSuccess 方法内根据 index 对数据操作。
elementui el-upload 在v-for里使用时 如何获取index的更多相关文章
- ElementUI的表单和vee-validate结合使用时发生冲突的解决
在Vue项目中使用ElementUI表单时,同时又引入了vee-validate进行使用的时候,在浏览器上会出现这样的报错: [Vue warn]: The computed property &qu ...
- 写一个函数int get(),这个函数运行一次可以从V[N]里随机取出一个数,而这个数必须是符合1/N平均分布的
题目:有一个函数int getNum(),每运行一次可以从一个数组V[N]里面取出一个数,N未知,当数取完的时候,函数返回NULL.现在要求写一个函数int get(),这个函数运行一次可以从V[N] ...
- ElementUI的Upload上传,配合七牛云储存图片
七牛云服务器的储存区域 存储区域 地域简称 上传域名 华东 z0 服务器端上传:http(s)://up.qiniup.com 华东 z0 客户端上传: http(s)://upload.qiniup ...
- 阿里云OSS 服务端签名后直传之分片上传(结合element-ui的upload组件)
分片上传(结合element-ui的upload组件实现自定义上传) async uploadFree(content){ let data = await this.getOssToken(); / ...
- element-ui(vue)upload组件的http-request方法的使用
element-ui(vue)upload组件的http-request方法的使用 官方文档: http-request方法有一个默认的参数 content content 是一个object对象:里 ...
- Saiku嵌入系统使用时传参数访问saiku(十六)
Saiku嵌入系统使用时传参数访问saiku Saiku通过iframe嵌入其他系统使用时,我们可以设定参数信息,然后根据url中参数对结果进行筛选哦. 这里我们实现的是根据日期字段进行范围查询,UR ...
- EntityFrameWork 使用时碰到的小问题
EntityFrameWork 使用时碰到的小问题 1,在使用orm访问数据库的相目里,也要引用EntityFrameWork.dll,否则无法使用orm 否则,编译错误 错误 5 "Sys ...
- PowerDesigner15使用时的十五个问题
15个问题列表: No.1:是不是一定要从CDM开始设计,然后在进行PDM的设计? NO.2:工具栏palette不见了,如何把它找出来? NO.3: 如何建立与数据库的关联? NO.4: 域和数据项 ...
- Eclipse和Android Studio中的DDMS使用时什么不同?
http://www.jb51.net/softjc/454131.html Eclipse和Android Studio中的DDMS使用时什么不同? 相信很多经常开发Android应用的朋友应该都接 ...
随机推荐
- 测试连接失败,因为初始化提供程序时发生错误,[DBNMPNTW] ConnectionOpen (CreateFile())
此主题相关图片如下:错误.jpg 今天发布的程序,在其它电脑上运行没问题,就是其中一台电脑上运程报这个错.系统是Win7的查了好久,最后解决 方法如下: 在报错的电脑上,单击"开始" ...
- 通用类 对象Excel互转
public class ExcelHelper { public void Demo(string filePath) { if (File.Exists(filePath)) File.Delet ...
- LeetCode编程训练 - 回溯(Backtracking)
回溯基础 先看一个使用回溯方法求集合子集的例子(78. Subsets),以下代码基本说明了回溯使用的基本框架: //78. Subsets class Solution { private: voi ...
- 【RL-TCPnet网络教程】第32章 RL-TCPnet之Telnet服务器
第32章 RL-TCPnet之Telnet服务器 本章节为大家讲解RL-TCPnet的Telnet应用,学习本章节前,务必要优先学习第31章的Telnet基础知识.有了这些基础知识之后,再搞 ...
- [Swift]LeetCode268. 缺失数字 | Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
- [Swift]LeetCode977. 有序数组的平方 | Squares of a Sorted Array
Given an array of integers A sorted in non-decreasing order, return an array of the squares of each ...
- awk小例子_1_逆序排列
seq 3 | awk '{ lifo[NR]=$0 } END{ for(lno=NR;lno>-1;lno--){ print lifo[lno]; } }' 结果:3 2 1 空行(lno ...
- ubuntu中环境变量的几个问题思考
问题一:export PATH=$PATH:/usr/local和export PATH=/usr/local:$PATH这两个的区别是什么?可以随便用吗? 这两个都是要把该目录加到环境变量中,一般的 ...
- spark对elasticsearch增删查改
增 新建一个 dataframe ,插入到索引 _index/_type ,直接调用 saveToEs ,让 _id 为自己设定的 id: import org.elasticsearch.spark ...
- Chapter 5 Blood Type——23
I didn't answer. I closed my eyes again and fought the nausea with all my strength, clamping my lips ...