product-item.vue 1.03 KB
<template>
  <div class="product-wrapper" @click="onclick">
      <img class="image-cls" :src="url" alt="" srcset="">
      <div class="price">{{price}}</div>
  </div>
</template>

<script>
export default {
  name: 'ProductItem',
  props: {
    pid: {
      type: String,
      default() {
        return '1212';
      }
    },
    url: {
      type: String,
      default() {
        return '//tvax2.sinaimg.cn/crop.0.0.828.828.50/006IPkwKly8fyhr791kkxj30n00n0q3u.jpg';
      }
    },
    price: {
      type: String,
      default() {
        return '¥121314';
      }
    }
  },
  methods: {
    onclick() {
      console.log('click product');
    }
  },
};
</script>

<style lang="scss" scoped>
.product-wrapper {
  display: inline-block;
  position: relative;
  width: 100px;
  height: 100px;
}

.image-cls {
  width: 100px;
  height: 100px;
}

.price {
  width: 100%;
  height: 28px;
  line-height: 28px;
  font-size: 20px;
  position: absolute;
  bottom: 0;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  color: white;
}
</style>