<template>
  <div class="listBox">
    <a v-for="(item, index) in imgList" :key="index" @click="selectImg(item)">
      <img :src="item.url" class="contain" alt>
    </a>
  </div>
</template>

<script>
export default {
  name: 'imglist',
  props: [
    'imgList'
  ],
  methods: {
    selectImg (item) {
      this.imgList.filter()
    }
  }
}
</script>

<style lang="scss" scoped>
.listBox {
  font-size: 0;
}
.listBox > * {
  display: inline-block;
  margin: 15px 15px 0 0;
  position: relative;
  overflow: hidden;
}
.listBox > *:first-child {
}
.listBox > a {
  width: 148px;
  height: 148px;
  box-sizing: border-box;
  border: 1px dashed #c0ccda;
  border-radius: 6px;
  background: #fff;
}

.listBox > a:hover {
  cursor: pointer;
}

.listBox > a::after {
  content: "";
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
  display: none;
}

.listBox > a::before {
  content: "删除";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  text-align: center;
  color: #fff;
  font-size: 16px;
  z-index: 11;
  display: none;
}

.listBox > a:hover::before,
.listBox > a:hover::after {
  display: block;
}

.listBox > a img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  z-index: 1;
}
</style>
