鸿宇研学生前端代码
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.

114 lines
2.2 KiB

  1. <template>
  2. <view class="list">
  3. <view class="list-item" v-for="item in list" :key="item.id">
  4. <view class="flex user">
  5. <view class="avatar">
  6. <image class="img" :src="item.avatar" mode="scaleToFill"></image>
  7. </view>
  8. <view class="name">{{ item.name }}</view>
  9. <view class="time">{{ item.createTime }}</view>
  10. </view>
  11. <view class="flex content">
  12. <view class="content-text">{{ item.content }}</view>
  13. <view class="content-img">
  14. <image class="img" v-if="getCoverImg(item)" :src="getCoverImg(item)" mode="aspectFill"></image>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. props: {
  23. list: {
  24. type: Array,
  25. default() {
  26. return []
  27. }
  28. }
  29. },
  30. methods: {
  31. getCoverImg(obj) {
  32. const { image } = obj
  33. return image?.split?.(',')?.[0]
  34. },
  35. },
  36. }
  37. </script>
  38. <style scoped lang="scss">
  39. .list {
  40. padding: 32rpx;
  41. background: #FAFAFA;
  42. border: 2rpx solid #FFFFFF;
  43. border-radius: 32rpx;
  44. &-item {
  45. & + & {
  46. margin-top: 40rpx;
  47. }
  48. }
  49. }
  50. .user {
  51. justify-content: flex-start;
  52. .avatar {
  53. width: 48rpx;
  54. height: 48rpx;
  55. border: 4rpx solid #FFFFFF;
  56. border-radius: 50%;
  57. overflow: hidden;
  58. .img {
  59. width: 100%;
  60. height: 100%;
  61. }
  62. }
  63. .name {
  64. margin-left: 8rpx;
  65. font-size: 36rpx;
  66. font-weight: 600;
  67. line-height: 1;
  68. color: #252545;
  69. }
  70. .time {
  71. margin-left: 16rpx;
  72. font-size: 24rpx;
  73. line-height: 1;
  74. color: #8B8B8B;
  75. }
  76. }
  77. .content {
  78. margin-top: 24rpx;
  79. &-text {
  80. flex: 1;
  81. font-size: 32rpx;
  82. color: #181818;
  83. overflow: hidden;
  84. text-overflow: ellipsis;
  85. display:-webkit-box; //作为弹性伸缩盒子模型显示。
  86. -webkit-box-orient:vertical; //设置伸缩盒子的子元素排列方式--从上到下垂直排列
  87. -webkit-line-clamp:4; //显示的行
  88. }
  89. &-img {
  90. flex: none;
  91. width: 190rpx;
  92. height: 190rpx;
  93. border-radius: 16rpx;
  94. overflow: hidden;
  95. .img {
  96. width: 100%;
  97. height: 100%;
  98. }
  99. }
  100. }
  101. </style>