新建组件like
<template>
<div class="like">
<Card>
<span>猜你喜欢</span>
</Card>
<ul>
<li v-for="(item, index) in LikeList" :key="index">
<h2><img :src="item.imgUrl" alt="" /></h2>
<h3>{{ item.name }}</h3>
<div class="price">
<span>$</span><b>{{ item.price }}</b>
</div>
</li>
</ul>
</div>
</template>
<script>
import Card from "@/components/home/Card";
export default {
components: {
Card,
},
data() {
return {
LikeList: [
{
id: 1,
name: "建开荼具套装,红色苏州市12件套",
price: 68,
imgUrl: "./images/n1.jpeg",
},
{
id: 2,
name: "建开荼具套装,红色苏州市12件套",
price: 68,
imgUrl: "./images/n2.jpeg",
},
{
id: 3,
name: "建开荼具套装,红色苏州市12件套",
price: 68,
imgUrl: "./images/n3.jpeg",
},
{
id: 4,
name: "建开荼具套装,红色苏州市12件套",
price: 68,
imgUrl: "./images/n4.jpeg",
},
],
};
},
};
</script>
<style scoped>
.like ul {
display: flex;
flex-wrap: wrap;
}
.like ul li {
display: flex;
flex-direction: column;
/* justify-content: center; */
align-items: center;
width: 50%;
}
.like h3 {
padding: 0.16rem;
width: 100%;
font-size: 00.42666rem;
font-weight: normal;
color: #222;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.like img {
width: 4.6933rem;
height: 4.6933rem;
}
.price {
width: 100%;
padding-left: 0.4rem;
color: red;
font-size: 0.4267rem;
text-align: left;
margin-bottom: 0.3rem;
}
</style>
|