参考: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异步加载轮播图,并且懒加载的更多相关文章

  1. VUE swiper.js引用使用轮播图

    <template> <div class="home"> <div class="swiper-container"> & ...

  2. iOS最笨的办法实现无限轮播图(网络加载)

    iOS最笨的办法实现无限轮播图(网络加载) 简单的做了一下: 使用方法: 把 请求返回的 图片地址(字符串类型)放进数组中就行 可以使用SDWebImage(我就是用的这个)等..需要自己导入并引用, ...

  3. 微信小程序之视图容器(swiper)组件创建轮播图

    一.视图容器(Swiper) 1.swiper:滑块视图容器 微信官方文档:https://developers.weixin.qq.com/miniprogram/dev/component/swi ...

  4. swiper结合ajax的轮播图

    Swiper 是什么:是纯JavaScript打造的滑动特效插件,能够实现触屏焦点图.触屏tab切换.触屏多图切换等常用效果. 开源.免费.稳定.应用广泛. 这就是swiper简单的介绍,由于是结合a ...

  5. swiper框架,实现轮播图等滑动效果

    http://www.swiper.com.cn/ 做个记录而已,这个没什么好说的,对于需要手机端开发实现触摸等方式可以看看.

  6. iOS开发之 用第三方类库实现轮播图

    在github上面有很多的第三方类库,大大节约了大家的开发时间 下载地址:https://github.com/gsdios/SDCycleScrollView 现已支持cocoapods导入:pod ...

  7. 用jQuery实现轮播图效果,js中的排他思想

    ---恢复内容开始--- jQuery实现轮播图不用单独加载. 思路: a. 通过$("#id名");选择需要的一类标签,获得一个伪数组 b.由于是伪数组的原因,而对数组的处理最多 ...

  8. Flask实战第53天:cms编辑轮播图功能完成

    后端逻辑 表单验证, 这里编辑就是和添加的内容一样,所以可以直接继承添加轮播图的表单验证,然后多加一个轮播图的id即可 编辑cmd.forms.py class UpdateBannerForm(Ad ...

  9. vue-awesome-swiper实现轮播图

    1.首先通过npm安装vue-awesome-swiper,我在项目中用的是2.6.7版本 npm install vue-awesome-swiper@2.6.7 –save 2. 在main.js ...

随机推荐

  1. idea中添加mysql驱动jia包的方法

    1 将相关jar包拷贝到自己所建的lib 文件夹下  如下图所示 2   选中自己的module  接着选择Project Structure 如下图 3 接着如下图继续操作 如上图完成后  那么我们 ...

  2. error C2443: operand size conflict

    #include <stdio.h> void main() { int a=98; __asm {     mov al,a     and al,11011111B     mov a ...

  3. Xcode输出中文

    重写NSArray和NSDictionary分类Category就OK了! 导入头文件 #import <objc/runtime.h> + (void)load { static dis ...

  4. HDU1595-find the longest of the shortest-dijkstra+记录路径

    Marica is very angry with Mirko because he found a new girlfriend and she seeks revenge.Since she do ...

  5. 剑指offer——37复杂链表的复制

    题目描述 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head.(注意,输出结果中请不要返回参数中的节点引用,否 ...

  6. Java多线程(五)之BlockingQueue深入分析

    一.概述: BlockingQueue作为线程容器,可以为线程同步提供有力的保障.   二.BlockingQueue定义的常用方法 1.BlockingQueue定义的常用方法如下:  1)add( ...

  7. 2018湘潭大学程序设计竞赛【H】

    题目链接:https://www.nowcoder.com/acm/contest/105/H 题意:两个操作,一个在[l,r]区间放颜色为c的球,一个统计在[l,r]里有多少不同颜色的球. 题解:哎 ...

  8. Oracle SQL外连接

    SQL提供了多种类型的连接方式,它们之间的区别在于:从相互交叠的不同数据集合中选择用于连接的行时所采用的方法不同.连接类型        定义内连接           只连接匹配的行左外连接     ...

  9. ES6 学习 -- let const

    看过很多大佬的ES6笔记,总结一下学习后的收获,给自己当作一个笔记用用: ES3.ES5定义变量有两种方法:var 和 function ES6定义变量有var.function.let.const等 ...

  10. cocos2D-X LUA 常用功能封装和工作经验的一些解决方案

    --[[ Packaging_KernelEngine.h 文件说明:所有对象在建立时位置是优先的,传入位置参数必须cc.p(X,Y) CurObj:表示要传入当前的对象 将3.10 lua api ...