App.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div>
  3. <!-- <h1>APP</h1> -->
  4. <!-- <van-button type="primary">主要按钮</van-button>
  5. <van-button type="success">成功按钮</van-button>
  6. <van-button type="default">默认按钮</van-button>
  7. <van-button type="danger">危险按钮</van-button>
  8. <van-button type="warning">警告按钮</van-button> -->
  9. <!-- <hr />
  10. <hr />
  11. <hr /> -->
  12. <!-- <Count></Count> -->
  13. <div class="product-list">
  14. <div v-for="(item, index) in list" :key="index">
  15. <div class="list-title">
  16. <span>{{ item.title }}</span>
  17. <span>查看更多</span>
  18. </div>
  19. <van-grid :column-num="3">
  20. <van-grid-item
  21. v-for="(item1, index1) in item.productDtoList"
  22. :key="index1"
  23. class="news"
  24. >
  25. <van-image
  26. :src="item1.pic"
  27. />
  28. <p class="prodName">{{ item1.prodName }}</p>
  29. <p>¥{{ item1.price }}</p>
  30. </van-grid-item>
  31. </van-grid>
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <script lang="ts" setup>
  37. import axios from "axios";
  38. import { ref, reactive, onMounted } from "vue";
  39. // import Count from "./components/Count.vue";
  40. onMounted(() => {
  41. getProductMain();
  42. });
  43. let list = ref([]);
  44. const getProductMain = async () => {
  45. let res = await axios.get(
  46. "http://shop-api.edu.koobietech.com/prod/tagProdList"
  47. );
  48. console.log(res);
  49. list.value = res.data.data;
  50. console.log(list.value);
  51. };
  52. </script>
  53. <style scoped>
  54. .news {
  55. width: 125px;
  56. }
  57. .prodName {
  58. width: 125px;
  59. font-size: 10px;
  60. /* overflow: hidden;
  61. white-space: nowrap;
  62. text-overflow: ellipsis; */
  63. display: -webkit-box;
  64. -webkit-line-clamp: 2;
  65. overflow: hidden;
  66. -webkit-box-orient: vertical;
  67. }
  68. </style>