element-ui upload 照片墙 照片回显
2019-06-08 12:15
155 查看
转载自https://blog.csdn.net/jiangjiang_ing/article/details/88977725
<el-form-item label="海报" prop="invitationPosterUrl"> <el-upload :file-list="fileList" //这里要设置!!! action="/admin/upload" list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove" :on-success="handleSuccess" > <i class="el-icon-plus"></i> </el-upload> <el-dialog :visible.sync="dialogVisible" :modal-append-to-body="false"> <img width="100%" :src="dialogImageUrl" alt> </el-dialog> </el-form-item> data() { return { fileList: [], items: [], urlObj: {}, dialogImageUrl: "", invitationFirst: "", urlArr: [], } } methods: { getList() {//这个函数可以不用看 这是获取后台完整的数据 this.listLoading = true; this.listQuery.isAsc = false; fetchList(this.listQuery).then(response => { this.list = response.data.records; this.list.map(val => { //仅展示第一张海报 后台传回以;分割图片网址的字符串,这里开始分割 if (val.invitationPosterUrl != null) { const invitationurlArr = val.invitationPosterUrl.split(";"); this.urlArr = invitationurlArr; const invitationurl = invitationurlArr[0]; val.invitationFirst = invitationurl; } }); this.total = response.data.total; this.listLoading = false; }); }, //编辑 handleUpdate(row) { this.fileList = []; this.urlArr = []; getObj(row.id).then(response => { this.form = response.data.data; if ( this.form.invitationPosterUrl != "" && this.form.invitationPosterUrl != null ) { //分割网址插入this.fileList图片就可以展示出来了 this.items = this.form.invitationPosterUrl.split(";"); this.items.forEach(val => { this.urlObj.url = val; this.urlArr.push(val) this.fileList.push(this.urlObj); this.urlObj = {}; }); } this.dialogFormVisible = true; this.dialogStatus = "update"; }); }, update(formName) { const set = this.$refs; set[formName].validate(valid => { if (valid) { this.dialogFormVisible = false; this.form.password = undefined; putObj(this.form).then(() => { this.dialogFormVisible = false; this.getList(); this.$notify({ title: "成功", message: "修改成功", type: "success", duration: 2000 }); }); } else { return false; } }); }, handleSuccess(jsonData, field) {//上传图片成功传给后台的数据 this.urlArr.push(jsonData.filename); this.urlString = this.urlArr.join(";"); this.form.invitationPosterUrl = this.urlString; }, handleRemove(file, fileList) {//移除图片传给后台的数据 this.urlArr = []; if (fileList.length == 0) { this.form.invitationPosterUrl = null; } else { fileList.forEach(item => { this.urlArr.push(item.url); this.urlString = this.urlArr.join(";"); this.form.invitationPosterUrl = this.urlString; }); } }, handlePictureCardPreview(file) {//点击放大图片 this.dialogImageUrl = file.url; this.dialogVisible = true; } }
相关文章推荐
- element-ui中upload组件如何传递文件及其他参数
- 阿里OSS Java-SDK带进度条上传,配合前端element-ui upload组件使用示例
- Element-ui框架修改-upload、step
- Upload 上传 以及图片不显示问题 element-ui
- 七牛云图片上传:使用element-ui的upload组件
- 在vue项目中使用element-ui的Upload上传组件
- 解决vue2.0 element-ui中el-upload的before-upload方法返回false时submit()不生效问题
- element UI upload组件上传附件格式限制方法
- elementui el-upload附件上传--上传之前需要修改文件内容
- Vue上传文件:ElementUI中的upload实现
- vue+elementui的table行内实现el-upload文件添加/多文件上传
- vue+element-ui--upload
- 完美解决Vue+element-ui 中upload组件使用多个时无法绑定对应的元素
- vue2.0 使用element-ui里的upload组件实现多图上传。采用FORMDATA的方式上传。
- vue2.0 使用element-ui里的upload组件实现图片预览效果方法
- vue+elementui el-upload上传文件携带参数
- element-ui upload使用经验总结
- 解决使用elementUI框架el-upload上传组件时session丢失问题
- vue2.0 使用element-ui里的upload组件实现图片预览效果
- 在vue项目中使用element-ui的Upload上传组件的示例