参考: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. Python pillow库安装报错

    报错信息: D:\pythontest\duanxinhongzha>pip3 install pillowCollecting pillow Could not find a version ...

  2. delphi编程实现为Windows窗口标题栏添加新按钮

    下面我们就讨论一下在delphi中如何给窗口的标题栏上添加新的按钮. 一.实现起来要定义以下过程: 1. 定义DrawCaptButton过程,这个过程的功能是在指定的位置画出按钮. 在过程中要使用w ...

  3. eclipse打包插件net.sf.fjep.fatjar

    eclipse打包插件安装 1)将net.sf.fjep.fatjar_0.0.32.jar拷贝到eclipse安装目录中的plugins目录下,然后重启eclipse即可. 软件获取方式: 链接:h ...

  4. Feign连接超时 Read timed out

    在远程调用的过程中由于连接超时,导致无法成功请求数据,下面是报错 项目中用的是spring-cloud-starter-openfeign 2.2.0版本 找到对应的文档,开始查阅资料 文档首页就找到 ...

  5. NX二次开发-创建圆弧(圆心-半径)UF_CURVE_create_arc_center_radius

    NX9+VS2012 #include <uf.h> #include <uf_curve.h> #include <uf_modl.h> UF_initializ ...

  6. C++输入cin详解

    输入原理: 程序的输入都建有一个缓冲区,即输入缓冲区.一次输入过程是这样的,当一次键盘输入结束时会将输入的数据存入输入缓冲区,而cin函数直接从输入缓冲区中取数据.正因为cin函数是直接从缓冲区取数据 ...

  7. faster-rcnn代码阅读-rpn-data层

    这一节讲述rpn-data层,和这一层有关的结构图如下: rpn-data层的prototxt定义如下: layer { name: 'rpn-data' type: 'Python' bottom: ...

  8. 记录装CDH新增加一些遇到问题的解决

    报错信息:MainThread agent ERROR Heartbeating to localhost:7182 failed.解决:配置CM Agentcm的安装包的server和agent都是 ...

  9. 三角形的实现和盒模型、层模型、浮动模型、定位、权重、margin问题

    相邻的border会平分所占的区域,出现一个斜线, .my_triangle{ width: 10px; height: 10px; background-color: blue; border-wi ...

  10. sslforfree的证书合并成类似于certbot的ssl证书文件

    之前的證書都是通過 certbot的命令生成的,但是目前一個服務器太多個網站,太多個ssl證書,證書過期之後,目前是 通過 ssl for free 網站再生成新的 ssl證書,再次更新證書週期 Le ...