-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
119 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
<markdown> | ||
# Lazy load | ||
|
||
You can use `lazy` to let image load after it enters viewport. | ||
</markdown> | ||
|
||
<template> | ||
<n-image | ||
v-for="(item, index) in Array(10)" | ||
:key="index" | ||
width="100" | ||
src="https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg" | ||
lazy | ||
:lazy-options="{ | ||
root: '.n-layout--static-positioned' | ||
}" | ||
/> | ||
<div | ||
id="image-scroll-container" | ||
style="overflow: auto; height: 100px; display: flex; flex-direction: column" | ||
> | ||
<n-image | ||
v-for="(src, index) in srcList" | ||
:key="index" | ||
width="100" | ||
height="100" | ||
lazy | ||
:src="src" | ||
:intersection-observer-options="{ | ||
root: '#image-scroll-container' | ||
}" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
export default defineComponent({ | ||
setup () { | ||
return { | ||
srcList: [ | ||
'https://picsum.photos/id/1/100/100', | ||
'https://picsum.photos/id/2/100/100', | ||
'https://picsum.photos/id/3/100/100', | ||
'https://picsum.photos/id/4/100/100', | ||
'https://picsum.photos/id/5/100/100', | ||
'https://picsum.photos/id/6/100/100', | ||
'https://picsum.photos/id/7/100/100', | ||
'https://picsum.photos/id/8/100/100', | ||
'https://picsum.photos/id/9/100/100', | ||
'https://picsum.photos/id/10/100/100' | ||
] | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
<markdown> | ||
# 懒加载 | ||
|
||
你可以使用 `lazy` 属性让图片进入视口再加载。 | ||
</markdown> | ||
|
||
<template> | ||
<n-image | ||
v-for="(item, index) in Array(10)" | ||
:key="index" | ||
width="100" | ||
src="https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg" | ||
lazy | ||
:lazy-options="{ | ||
root: '.n-layout--static-positioned' | ||
}" | ||
/> | ||
<div | ||
id="image-scroll-container" | ||
style="overflow: auto; height: 100px; display: flex; flex-direction: column" | ||
> | ||
<n-image | ||
v-for="(src, index) in srcList" | ||
:key="index" | ||
width="100" | ||
height="100" | ||
lazy | ||
:src="src" | ||
:intersection-observer-options="{ | ||
root: '#image-scroll-container' | ||
}" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
export default defineComponent({ | ||
setup () { | ||
return { | ||
srcList: [ | ||
'https://picsum.photos/id/1/100/100', | ||
'https://picsum.photos/id/2/100/100', | ||
'https://picsum.photos/id/3/100/100', | ||
'https://picsum.photos/id/4/100/100', | ||
'https://picsum.photos/id/5/100/100', | ||
'https://picsum.photos/id/6/100/100', | ||
'https://picsum.photos/id/7/100/100', | ||
'https://picsum.photos/id/8/100/100', | ||
'https://picsum.photos/id/9/100/100', | ||
'https://picsum.photos/id/10/100/100' | ||
] | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters