product-item.vue
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<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>