获得徽章 0
前端工程师 @.
前端工程师 @.
前端工程师 @.
前端工程师 @.
关注了
祯民
VIP.5 如鱼得水
前端工程师 @.
cursor 的一些使用技巧分享:github.com
评论
#每天一个知识点# ```
function importAll(r: RequireContext) {
return r.keys().map(r).filter((item: string) => item.includes('popup'));
}
// 预加载图片
const images = importAll(require.context('./assets/images/myLikeList/', false, /\.(png|jpe?g|svg)$/));
// images 为类似import引进的图片集合

1、第一种方式加载图片
images.forEach((image: string) => {
const img = new Image()
img.src = image;
img.onload = () => {
console.log('图片加载完成')
}
})
2、第二个采用dom
<img v-for="(item, index) in images" :src="item" :key="index" style="display: none" />
```
我的问题是:请问这两种方法有什么不同吗?现象是 采用第一种方式的,图片还是会重新加载,而采用第二种的没有。
展开
评论
关注了
前端工程师 @.
下一页
个人成就
文章被点赞 5
文章被阅读 3,277
掘力值 70
收藏集
5
关注标签
4
加入于