Commit 6775c240 by 张杰

优化图片组件

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