my-grid.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view>
  3. <van-grid column-num="2" :gutter="10">
  4. <van-grid-item v-for="(item,idx) in shops" icon="photo-o" @click="nevigateToDetail(item)" :text="item.text" :key="idx" :use-slot="true">
  5. <slot name="icon">
  6. <!-- <van-icon name="chat" color="red"></van-icon>-->
  7. <image :src="item.imgUrl" class="itemImg"></image>
  8. <!-- <van-image></van-image>-->
  9. </slot>
  10. <slot name="text" :item="item">
  11. <!-- <view v-if="idx%2" style="background-color: red">去摸鱼儿Isaac查看啊啊啊啊</view>-->
  12. <!-- <view style="font-weight: bold;font-size: 20px">{{ item.name | truncate(15)}}123</view>-->
  13. <view>{{ item.shopInfo | truncate(15)}}</view>
  14. </slot>
  15. </van-grid-item>
  16. </van-grid>
  17. <!-- 123-->
  18. <!-- <van-row gutter="20">-->
  19. <!-- <van-col span="20">-->
  20. <!--&lt;!&ndash; <my-grid-item></my-grid-item>&ndash;&gt;-->
  21. <!-- <view style="width: 40%">-->
  22. <!-- <image src="@/static/logo.png" style="width: 40%;height: auto"></image>-->
  23. <!-- 123-->
  24. <!-- </view>-->
  25. <!-- </van-col>-->
  26. <!-- <van-col span="20">-->
  27. <!-- <view style="width: 40%">-->
  28. <!-- <image src="@/static/logo.png"></image>-->
  29. <!-- 123-->
  30. <!-- </view>-->
  31. <!-- </van-col>-->
  32. <!-- </van-row>-->
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. grid_data:[{text:"冰美式"},{text:"古茗"},{text:"热咖"},{text:"白茶"},
  40. {text:"冰美式"},{text:"古茗"},{text:"热咖"},{text:"白茶"},
  41. {text:"冰美式"},{text:"古茗"},{text:"热咖"}]
  42. };
  43. },
  44. props: {
  45. shops: {
  46. type: Array,
  47. default: () => []
  48. },
  49. },
  50. methods: {
  51. nevigateToDetail(item){
  52. uni.navigateTo({
  53. url: `/subpkg/shopdetail/shopdetail?shopID=${JSON.stringify(item.id)}`
  54. })
  55. }
  56. },
  57. filters: {
  58. truncate(value, length = 10) {
  59. if (!value) return ''
  60. if (value.length > length) {
  61. return value.slice(0, length) + '...'
  62. }
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. .itemImg{
  69. width: 300rpx;
  70. height: 300rpx;
  71. }
  72. </style>