<template>
|
|
<view class="article-item" @click="handleClick">
|
|
<view class="image-container">
|
|
<image :src="item.image" mode="aspectFill" class="article-image" />
|
|
</view>
|
|
<view class="content-container">
|
|
<text class="article-title">{{ item.title }}</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'ArticleItem',
|
|
props: {
|
|
item: {
|
|
type: Object,
|
|
required: true,
|
|
default: () => ({
|
|
title: '',
|
|
image: ''
|
|
})
|
|
}
|
|
},
|
|
methods: {
|
|
handleClick() {
|
|
this.$emit('click', this.item);
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.article-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: #fff;
|
|
border-radius: 12rpx;
|
|
overflow: hidden;
|
|
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
|
|
margin-bottom: 20rpx;
|
|
transition: transform 0.2s ease;
|
|
|
|
&:active {
|
|
transform: scale(0.98);
|
|
}
|
|
}
|
|
|
|
.image-container {
|
|
width: 100%;
|
|
height: 300rpx;
|
|
overflow: hidden;
|
|
|
|
.article-image {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
}
|
|
|
|
.content-container {
|
|
padding: 20rpx;
|
|
|
|
.article-title {
|
|
font-size: 30rpx;
|
|
font-weight: 500;
|
|
color: #333;
|
|
line-height: 1.6;
|
|
display: -webkit-box;
|
|
-webkit-box-orient: vertical;
|
|
-webkit-line-clamp: 2;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
}
|
|
</style>
|