topic-grid-list.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view class="zaiui-topic-grid-box">
  3. <scroll-view class="scroll-view" scroll-x>
  4. <block v-for="(item,index) in list_data" :key="item.id">
  5. <view :id="['topicGrid' + (index + 1 )]" class="scroll-item" @tap="listTap(items,index)">
  6. <view class="cu-avatar radius" :style="[{backgroundImage:'url('+ item.img +')'}]"/>
  7. <view class="bg-shade"/>
  8. <view class="text-sm text">{{item.title}}</view>
  9. </view>
  10. </block>
  11. </scroll-view>
  12. </view>
  13. </template>
  14. <script>
  15. import _tool from '@/static/zaiui/util/tools.js';
  16. export default {
  17. name: 'topic-grid-list',
  18. props: {
  19. list_data: {
  20. type: Array,
  21. default: () => {
  22. return []
  23. }
  24. }
  25. },
  26. methods: {
  27. listTap(data,index) {
  28. this.$emit('listTap', {
  29. data,
  30. index
  31. });
  32. }
  33. }
  34. }
  35. </script>
  36. <style lang="scss" scoped>
  37. .zaiui-topic-grid-box {
  38. position: relative;
  39. width: 100%;
  40. .scroll-view {
  41. position: relative;
  42. height: 118.18upx;
  43. white-space: nowrap;
  44. width: 100%;
  45. .scroll-item {
  46. display: inline-block;
  47. position: relative;
  48. border-radius: 9.09upx;
  49. margin: 0 9.09upx;
  50. width: 172.72upx;
  51. &:first-child {
  52. margin-left: 27.27upx;
  53. }
  54. &:last-child {
  55. margin-right: 27.27upx;
  56. }
  57. .cu-avatar {
  58. width: 172.72upx;
  59. height: 118.18upx;
  60. border-radius: 9.09upx;
  61. }
  62. .bg-shade {
  63. position: absolute;
  64. bottom: 0;
  65. top: 0;
  66. left: 0;
  67. right: 0;
  68. background-color: rgba(0, 0, 0, 0.2);
  69. border-radius: 9.09upx;
  70. }
  71. .text {
  72. position: absolute;
  73. bottom: 0;
  74. color: #fff;
  75. padding: 14.54upx 18.18upx;
  76. width: 100%;
  77. }
  78. }
  79. }
  80. }
  81. </style>