vben
authored
|
1
|
<template>
|
vben
authored
|
2
|
<PageWrapper title="懒加载基础示例" content="向下滚动到可见区域才会加载组件">
|
vben
authored
|
3
4
|
<div class="lazy-base-demo-wrap">
<h1>向下滚动</h1>
|
vben
authored
|
5
6
7
8
9
10
11
12
13
|
<div class="lazy-base-demo-box">
<LazyContainer>
<TargetContent />
<template #skeleton>
<Skeleton :rows="10" />
</template>
</LazyContainer>
</div>
|
vben
authored
|
14
|
</div>
|
vben
authored
|
15
|
</PageWrapper>
|
vben
authored
|
16
17
18
|
</template>
<script lang="ts">
import { defineComponent } from 'vue';
|
vben
authored
|
19
|
import { Skeleton } from 'ant-design-vue';
|
vben
authored
|
20
21
|
import TargetContent from './TargetContent.vue';
import { LazyContainer } from '/@/components/Container/index';
|
vben
authored
|
22
23
|
import { PageWrapper } from '/@/components/Page';
|
vben
authored
|
24
|
export default defineComponent({
|
vben
authored
|
25
|
components: { LazyContainer, PageWrapper, TargetContent, Skeleton },
|
vben
authored
|
26
27
|
});
</script>
|
vben
authored
|
28
|
<style lang="less">
|
vben
authored
|
29
30
31
32
33
34
35
|
.lazy-base-demo {
&-wrap {
display: flex;
width: 50%;
height: 2000px;
margin: 20px auto;
text-align: center;
|
Vben
authored
|
36
|
background-color: @component-background;
|
vben
authored
|
37
38
39
40
41
|
justify-content: center;
flex-direction: column;
align-items: center;
}
|
vben
authored
|
42
43
44
45
46
|
&-box {
width: 300px;
height: 300px;
}
|
vben
authored
|
47
48
49
50
51
52
|
h1 {
height: 1300px;
margin: 20px 0;
}
}
</style>
|