Blame view

src/views/demo/comp/lazy/index.vue 1.25 KB
1
2
3
4
5
<template>
  <div class="p-4 lazy-base-demo">
    <Alert message="基础示例" description="向下滚动到可见区域才会加载组件" type="info" show-icon />
    <div class="lazy-base-demo-wrap">
      <h1>向下滚动</h1>
6
7
8
9
10
11
12
13
14

      <div class="lazy-base-demo-box">
        <LazyContainer>
          <TargetContent />
          <template #skeleton>
            <Skeleton :rows="10" />
          </template>
        </LazyContainer>
      </div>
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    </div>
  </div>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { Skeleton, Alert } from 'ant-design-vue';
  import TargetContent from './TargetContent.vue';
  import { LazyContainer } from '/@/components/Container/index';
  export default defineComponent({
    components: { LazyContainer, TargetContent, Skeleton, Alert },
    setup() {
      return {};
    },
  });
</script>
30
<style lang="less">
31
32
33
34
35
36
37
38
39
40
41
42
43
  .lazy-base-demo {
    &-wrap {
      display: flex;
      width: 50%;
      height: 2000px;
      margin: 20px auto;
      text-align: center;
      background: #fff;
      justify-content: center;
      flex-direction: column;
      align-items: center;
    }
44
45
46
47
48
    &-box {
      width: 300px;
      height: 300px;
    }
49
50
51
52
53
54
    h1 {
      height: 1300px;
      margin: 20px 0;
    }
  }
</style>