vue swiper异步加载轮播图,并且懒加载
参考:https://blog.csdn.net/weixin_38304202/article/details/78282826
效果:

此处安装省略
vue:
<div class="banner" v-show="isShowSlide">
<div class="swiper-banner">
<div class="swiper-wrapper">
<div class="swiper-slide" v-for="(item,index) in swiperList" :key="index">
<img src="data:images/img_loading.jpg"
:data-src="item.imgpath" class="swiper-lazy" style="width:100%;height:100%">
</div>
</div>
<div class="swiper-pagination" v-if="swiperList.length>1">
<span v-for="(item,index) in swiperList"></span>
</div>
</div>
</div>
getImgs: function() { //created中调用
let _this = this;
_this.axios.get('请求链接').then(function(res) {
if (res.status === 200 && res.data.result === "0") {
const data = res.data.message.list;
for (let i in data) {
_this.swiperList.push(data[i]);
}
_this.swiperLength = _this.swiperList.length;
_this.$nextTick(function() {
if (_this.swiperLength > 0) {
_this.isShowSlide = true;
if (_this.swiperLength == 1) {
_this.isAutoplay = 0;
_this.isLoop = false;
} else {
_this.isAutoplay = 3000;
_this.isLoop = true;
}
_this.mySwiper = new Swiper(".swiper-banner", {
autoplay: _this.isAutoplay,
loop: _this.isLoop,
autoplayDisableOnInteraction: false,
preventLinksPropagation: false,
lazyLoading: true, //懒加载开启
pagination: '.swiper-pagination',
observer: true, //修改swiper自己或子元素时,自动初始化swiper
observeParents: true, //修改swiper的父元素时,自动初始化swiper
})
} else {
_this.isShowSlide = false;
}
})
} else {
_this.isShowSlide = false;
}
}).catch(function(err) {
console.log(err);
})
},
.swiper-wrapper {
font-size: 0;
}
.swiper-pagination {
width: 100%;
height: .2rem;
text-align: center;
position: absolute;
bottom: 0 !important;
line-height: .2rem;
box-sizing: border-box;
padding: 0 .3rem;
font-size: 0;
}
>>>.swiper-pagination-bullet-active {
background-color: #ff7035 !important;
opacity: 1;
}
.swiper-pagination-bullet {
background-color: rgba(255, 255, 255, 1);
opacity: 1;
}
.swiper-slide {
height: 1.5rem !important;
line-height: 1.5rem !important;
}
.swiper-wrapper {
width: 100% !important;
height: 100% !important;
}
.swiper-container-autoheight,
.swiper-container-autoheight .swiper-slide {
height: 100%;
font-size: 0;
position: relative;
}
vue swiper异步加载轮播图,并且懒加载的更多相关文章
- VUE swiper.js引用使用轮播图
<template> <div class="home"> <div class="swiper-container"> & ...
- iOS最笨的办法实现无限轮播图(网络加载)
iOS最笨的办法实现无限轮播图(网络加载) 简单的做了一下: 使用方法: 把 请求返回的 图片地址(字符串类型)放进数组中就行 可以使用SDWebImage(我就是用的这个)等..需要自己导入并引用, ...
- 微信小程序之视图容器(swiper)组件创建轮播图
一.视图容器(Swiper) 1.swiper:滑块视图容器 微信官方文档:https://developers.weixin.qq.com/miniprogram/dev/component/swi ...
- swiper结合ajax的轮播图
Swiper 是什么:是纯JavaScript打造的滑动特效插件,能够实现触屏焦点图.触屏tab切换.触屏多图切换等常用效果. 开源.免费.稳定.应用广泛. 这就是swiper简单的介绍,由于是结合a ...
- swiper框架,实现轮播图等滑动效果
http://www.swiper.com.cn/ 做个记录而已,这个没什么好说的,对于需要手机端开发实现触摸等方式可以看看.
- iOS开发之 用第三方类库实现轮播图
在github上面有很多的第三方类库,大大节约了大家的开发时间 下载地址:https://github.com/gsdios/SDCycleScrollView 现已支持cocoapods导入:pod ...
- 用jQuery实现轮播图效果,js中的排他思想
---恢复内容开始--- jQuery实现轮播图不用单独加载. 思路: a. 通过$("#id名");选择需要的一类标签,获得一个伪数组 b.由于是伪数组的原因,而对数组的处理最多 ...
- Flask实战第53天:cms编辑轮播图功能完成
后端逻辑 表单验证, 这里编辑就是和添加的内容一样,所以可以直接继承添加轮播图的表单验证,然后多加一个轮播图的id即可 编辑cmd.forms.py class UpdateBannerForm(Ad ...
- vue-awesome-swiper实现轮播图
1.首先通过npm安装vue-awesome-swiper,我在项目中用的是2.6.7版本 npm install vue-awesome-swiper@2.6.7 –save 2. 在main.js ...
随机推荐
- js条件语句,用if...else if....else方程ax2+bx+c=0一元二次方程。求根
if 语句 - 只有当指定条件为 true 时,使用该语句来执行代码 if...else 语句 - 当条件为 true 时执行代码,当条件为 false 时执行其他代码 if...else if... ...
- Struts功能详解——ValidatorForm
ActionForm和ValidatorForm区别: 一个Form继承了ValidatorForm 就不用写具体的验证,但是需要提供:validation-rules.xml 和 val ...
- 模拟字典序排序——hdu6034
#include <bits/stdc++.h> #include <iostream> using namespace std; ; ; int n; int maxj; s ...
- NX二次开发-设置尺寸的附加尺寸UF_DRF_set_appended_text
#include <uf.h> #include <uf_drf.h> #include <uf_obj.h> #include <uf_part.h> ...
- NX二次开发-UFUN获取图纸视图最大边界和视图中心点UF_DRAW_ask_view_borders
NX9+VS2012 //获得视图的最大边界 ]; UF_DRAW_ask_view_borders(view_tag[j], view_borders); //获得视图原点 ]; ViewOrigi ...
- NX二次开发-UFUN输入对象tag获得part名字UF_OBJ_ask_owning_part
NX11+VS2013 #include <uf.h> #include <uf_modl.h> #include <uf_part.h> #include < ...
- 史上最全Html和CSS布局技巧
单列布局水平居中 水平居中的页面布局中最为常见的一种布局形式,多出现于标题,以及内容区域的组织形式,下面介绍四种实现水平居中的方法(注:下面各个实例中实现的是child元素的对齐操作,child元 ...
- PAT L2-019. 悄悄关注 /// map set
https://www.patest.cn/contests/gplt/L2-019 题目大意: 新浪微博上有个“悄悄关注”,一个用户悄悄关注的人,不出现在这个用户的关注列表上,但系统会推送其悄悄关注 ...
- EFCore学习记录笔记
1:连接slqlocaldb数据库 (1)在CMD下可以输入sqllocaldb info 查看本机安装的所有的localdb实例 (2)数据库连接字符串为:“Server=(localdb)\\MS ...
- 唯一id
package com.debug.kill.server.utils; /** * Created by Administrator on 2019/6/20. */ import org.apac ...