Commit 6775c240 by 张杰

优化图片组件

1 parent ffe5852d
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="img_cell" v-for="(item,index) in imgList" :key="index"> <div class="img_cell" v-for="(item,index) in imgList" :key="index">
<div class="el_img_box"> <div class="el_img_box">
<i class="el-icon-error el_icon" @click="removeImage(item)" v-if="readStatus != 1"></i> <i class="el-icon-error el_icon" @click="removeImage(item)" v-if="readStatus != 1"></i>
<el-image class="el_img" :src="item.path" :preview-src-list="getPreViewList(item.path)"></el-image> <el-image class="el_img" :src="item.path" :preview-src-list="getPreViewList(item.path,imgList)"></el-image>
</div> </div>
</div> </div>
<!-- 图片列表 end --> <!-- 图片列表 end -->
...@@ -47,6 +47,7 @@ export default { ...@@ -47,6 +47,7 @@ export default {
uploadUrl: "", uploadUrl: "",
readStatus: "", readStatus: "",
acceptFile: ".jpg,.png", acceptFile: ".jpg,.png",
previewList: [],
}; };
}, },
watch: { watch: {
...@@ -126,6 +127,7 @@ export default { ...@@ -126,6 +127,7 @@ export default {
let response = res.data; let response = res.data;
if (response.returnCode == 0) { if (response.returnCode == 0) {
_this.imgList.push({ path: response.data }); _this.imgList.push({ path: response.data });
_this.previewList.push(res.data);
console.log(_this.imgList); console.log(_this.imgList);
// //
//this.$emit("change", response.data); //this.$emit("change", response.data);
...@@ -160,15 +162,16 @@ export default { ...@@ -160,15 +162,16 @@ export default {
// 获取图片预览列表 // 获取图片预览列表
getPreViewList(url) { getPreViewList(url) {
let _this = this;
let list = this.imgList || []; let list = this.imgList || [];
let arr = []; let arr = [];
list.map((k) => { list.map((k) => {
if (k.path != url) { if (k.pah == url) {
arr.psuh(k.path); arr.unshift(k.path);
} else {
arr.push(k.path);
} }
}); });
arr.unshift(url);
console.log(arr);
return arr; return arr;
}, },
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!