瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.2 KiB

  1. <template>
  2. <view class="article-item" @click="handleClick">
  3. <view class="image-container">
  4. <image :src="item.image" mode="aspectFill" class="article-image" />
  5. </view>
  6. <view class="content-container">
  7. <text class="article-title">{{ item.title }}</text>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'ArticleItem',
  14. props: {
  15. item: {
  16. type: Object,
  17. required: true,
  18. default: () => ({
  19. title: '',
  20. image: ''
  21. })
  22. }
  23. },
  24. methods: {
  25. handleClick() {
  26. this.$emit('click', this.item);
  27. }
  28. }
  29. }
  30. </script>
  31. <style scoped lang="scss">
  32. .article-item {
  33. display: flex;
  34. flex-direction: column;
  35. background: #fff;
  36. border-radius: 12rpx;
  37. overflow: hidden;
  38. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  39. margin-bottom: 20rpx;
  40. transition: transform 0.2s ease;
  41. &:active {
  42. transform: scale(0.98);
  43. }
  44. }
  45. .image-container {
  46. width: 100%;
  47. height: 300rpx;
  48. overflow: hidden;
  49. .article-image {
  50. width: 100%;
  51. height: 100%;
  52. object-fit: cover;
  53. }
  54. }
  55. .content-container {
  56. padding: 20rpx;
  57. .article-title {
  58. font-size: 30rpx;
  59. font-weight: 500;
  60. color: #333;
  61. line-height: 1.6;
  62. display: -webkit-box;
  63. -webkit-box-orient: vertical;
  64. -webkit-line-clamp: 2;
  65. overflow: hidden;
  66. text-overflow: ellipsis;
  67. }
  68. }
  69. </style>