index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div
  3. class="virtual-list"
  4. :style="{ height: list.length === 0 || list.length === 1 ? '600px' : '' }"
  5. >
  6. <div
  7. class="charts"
  8. v-if="list && list.length > 0"
  9. :style="{ height: list.length === 0 || list.length === 1 ? '600px' : '' }"
  10. >
  11. <RecycleScroller
  12. class="scroller"
  13. :items="list"
  14. :item-size="itemSize"
  15. :key-field="keyField"
  16. v-slot="{ item, index }"
  17. >
  18. <slot :item="item" :index="index"></slot>
  19. </RecycleScroller>
  20. </div>
  21. <el-empty description="暂无分析记录" v-else></el-empty>
  22. </div>
  23. </template>
  24. <script type="text/javascript">
  25. //import HelloWorld from '@/components/HelloWorld.vue'
  26. export default {
  27. name: "VirtualList",
  28. components: {},
  29. props: {
  30. list: {
  31. type: Array,
  32. default: () => [],
  33. },
  34. keyField: {
  35. type: String,
  36. default: "id",
  37. },
  38. itemSize: {
  39. type: Number,
  40. default: 300,
  41. },
  42. },
  43. data() {
  44. return {};
  45. },
  46. };
  47. </script>
  48. <style lang="scss" scoped>
  49. .charts {
  50. // height: calc(100% - 150px);
  51. height: 100%;
  52. }
  53. .virtual-list {
  54. height: 100%;
  55. display: flex;
  56. flex-direction: column;
  57. }
  58. .scroller {
  59. height: 100%;
  60. overflow: hidden;
  61. /* 隐藏垂直滚动条 */
  62. &::-webkit-scrollbar {
  63. width: 0;
  64. }
  65. /* 隐藏水平滚动条 */
  66. &::-webkit-scrollbar {
  67. height: 0;
  68. }
  69. }
  70. </style>