guyu/components/guyu-home-container/home-recommend.vue
2025-07-23 23:42:09 +08:00

77 lines
1.7 KiB
Vue

<template>
<view v-if="recList && recList.length > 0" class="home-recommend">
<view
v-for="(item, index) in recList"
:key="index"
class="recommend-item"
@click="handleItemClick(index)"
>
<image :src="item.imageUrl" class="recommend-image" />
<text class="recommend-title myZt-500w">{{ item.name }}</text>
</view>
</view>
</template>
<script setup>
/**
* 首页推荐位组件
*/
import { defineProps, defineEmits } from 'vue';
// 组件属性
const props = defineProps({
/**
* 推荐列表
*/
recList: {
type: Array,
default: () => []
}
});
// 事件
const emit = defineEmits(['itemClick']);
/**
* 点击推荐项
* @param {Number} index 点击的索引
*/
const handleItemClick = (index) => {
emit('itemClick', index);
};
</script>
<style lang="scss" scoped>
.home-recommend {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
margin-top: 29.86rpx;
.recommend-item {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.recommend-image {
width: 159.72rpx;
height: 159.72rpx;
background-color: #FDF4D5;
border-radius: 40rpx;
}
.recommend-title {
margin-top: 13.19rpx;
font-size: 22.22rpx;
color: #685952;
width: 159.72rpx;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
}
}
</style>