当前位置:网站首页>16 【打包上线 图片懒加载】
16 【打包上线 图片懒加载】
2022-07-31 05:10:00 【DSelegent】
30.打包上线
vue.config.js
module.exports = {
//打包时不生成map文件(用来进行错误提示的文件,很占用空间)
productionSourceMap: false,
// 关闭ESLINT校验工具
lintOnSave: false,
}
pnpm run build
31.图片懒加载
懒加载vue-lazyload插件官网
插件的使用直接参考官方教程,很简单。
安装vue-lazyload插件
pnpm add [email protected] --save-dev
在main.js中进行引用
import VueLazyload from "vue-lazyload";
//或者自定义配置插件
Vue.use(VueLazyload, {
preLoad: 1.3,
error: require('@/assets/image/error.png'),
loading: require('@/assets/image/loading.gif'),
attempt: 1
})
各个自定义配置属性含义:
使用(将图片设置为懒加载)
<img v-lazy="psdimg" class="psd" />
注意:
当遇到是v-for循环的时候,或者用div包裹着img的时候,需要在div上面添加 v-lazy-container="{ selector: ‘img’ }"
<div v-lazy-container="{ selector: 'img' }">
<img data-src="//aaa.com/img1.jpg">
<img data-src="//aaa.com/img2.jpg">
<img data-src="//aaa.com/img3.jpg">
</div>
<!--或者这种:-->
<div v-lazy-container="{ selector: 'img' }" v-html="content">
</div>
如果是这种情况的话,一定要使用 data-src 来指定路径,而不使用v-lazy。因为如果使用的是v-lazy的话,拿到了图片地址也会一直显示不出来。
边栏推荐
- 剑指offer专项突击版 ---- 第2天
- Input length must be multiple of 8 when decrypting with padded cipher
- tf.keras.utils.get_file()
- 剑指offer基础版 ----第31天
- torch.normal函数用法
- 剑指offer专项突击版 ---第 5 天
- 基于web3.0使用钱包Metamask的三方登陆
- The interviewer asked me TCP three handshake and four wave, I really
- <urlopen error [Errno 11001] getaddrinfo failed>的解决、isinstance()函数初略介绍
- Kubernetes加入集群的TOKEN值过期
猜你喜欢
【数据库学习】Redis 解析器&&单线程&&模型
运用flask框架发送短信验证码的流程及具体代码
Distributed Transactions - Introduction to Distributed Transactions, Distributed Transaction Framework Seata (AT Mode, Tcc Mode, Tcc Vs AT), Distributed Transactions - MQ
pycharm专业版使用
【JS面试题】面试官:“[1,2,3].map(parseInt)“ 输出结果是什么?答上来就算你通过面试
MySQL8.0安装教程,在Linux环境安装MySQL8.0教程,最新教程 超详细
【一起学Rust】Rust的Hello Rust详细解析
Refinement of the four major collection frameworks: Summary of List core knowledge
MYSQL下载及安装完整教程
With MVC, why DDD?
随机推荐
Kubernetes 证书可用年限修改
剑指offer专项突击版 ---第 5 天
2022-07-30:以下go语言代码输出什么?A:[]byte{} []byte;B:[]byte{} []uint8;C:[]uint8{} []byte;D:[]uin8{} []uint8。
关于小白安装nodejs遇到的问题(npm WARN config global `--global`, `--local` are deprecated. Use `--location=glob)
If the account number or password is entered incorrectly for many times, the account will be banned.
基于web3.0使用钱包Metamask的三方登陆
解决响应式数据依赖响应式数据无响应问题
Kubernetes加入集群的TOKEN值过期
The interviewer asked me TCP three handshake and four wave, I really
torch.normal function usage
Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构
uni-app进阶之模版语法与数据绑定【day7】
C语言教程(一)-准备
剑指offer专项突击版 --- 第 4 天
分布式事务处理方案大 PK!
Goodbye to the cumbersome Excel, mastering data analysis and processing technology depends on it
C语言实验二 数据类型、运算符和表达式
Pytorch教程Introduction中的神经网络实现示例
三子棋讲解(C语言)
Simple command of mysql