介绍:轮播使用了swiper,重要用于移动端滑动,详情可查看官网

1.首先用npm安装        npm install swiper

2.main.js 中引入CSS     import 'swiper/css/swiper.css'

3.新建swiper-slide.min.css文件

@charset "utf-8";*{margin:0;padding:0}html{height:100%}body{height:100%;
background-size:100% 100%
}#header img{width:100%}.swiper-container{width:100%;-webkit-perspective:1200px;-moz-perspective:1200px;-ms-perspective:1200px;perspective:1200px}.swiper-wrapper{margin-top:10px}.swiper-slide{width:80%;-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-ms-transform-style:preserve-3d;transform-style:preserve-3d}.swiper-slide .main-img{width:90%;margin:0 auto;display:block}#pagination{position:absolute;bottom:100px;width:100%}#pagination .swiper-pagination-bullet{width:9.5%;float:left;margin:0 0 0 6.15%;background:0;opacity:1}.swiper-pagination-bullet i{background:#41203f;width:24px;height:24px;line-height:24px;font-size:12px;border-radius:50px;display:block;font-style:normal;text-align:center;margin:0 auto;color:#f5b55c}
.swiper-pagination-bullet-active i{
-webkit-transform:scale(1.5);
background-size:auto 100%;color:#815d4b}@media screen and (min-height:481px){.swiper-wrapper{margin-top:20px}#pagination{bottom:110px}}@media screen and (min-height:569px){.swiper-wrapper{margin-top:40px}#pagination{bottom:120px}.swiper-pagination-bullet i{width:30px;height:30px;line-height:30px;font-size:15px}}#footer{position:absolute;bottom:0}#footer img{width:100%;display:block}

4.新建.vue文件,(根据自己喜欢选择不同效果)

<template>
<div class="onlyShow">
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide"
v-for="(item, index) in tabDataList"
:key="index"><img :src="item.logo"
class="main-img"></div>
</div> </div>
<div class="swiper-pagination"
id="pagination"></div>
</div>
</template> <script>
import Swiper from 'swiper' export default {
data() {
return {
tabDataList: [{
logo: require('@/assets/20191101144840.png')
}, {
logo: require('@/assets/20191101144840.png')
}, {
logo: require('@/assets/20191101144840.png')
}],
isPhone: false
};
},
mounted() {
var u = navigator.userAgent, app = navigator.appVersion;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isAndroid) {
this.isPhone = true
}
if (isIOS) {
this.isPhone = false
}
this.defaultFun()
},
methods: {
defaultFun() {
// 第一种方法,实现第一张图效果
var mySwiper = new Swiper(".swiper-container",
{
slidesPerView: "auto",
centeredSlides: !0,
watchSlidesProgress: !0,
pagination: ".swiper-pagination",
paginationClickable: !0,
paginationBulletRender: function (a, b) {
// switch (a) {
// case 0:
// name = "洗"; break; case 1: name = "剪"; break; case 2: name = "烫"; break; case 3: name = "染"; break; case 4: name = "护"; break; case 5: name = "套"; break; default: name = "" }return '<span class="' + b + '"><i>' + name + "</i></span>"
},
onProgress: function (a) {
var b, c, d; for (b = 0; b < a.slides.length; b++)c = a.slides[b], d = c.progress, scale = 1 - Math.min(Math.abs(.2 * d), 1), es = c.style, es.opacity = 1 - Math.min(Math.abs(d / 2), 1), es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = "translate3d(0px,0," + -Math.abs(150 * d) + "px)" }, onSetTransition: function (a, b) { for (var c = 0; c < a.slides.length; c++)es = a.slides[c].style, es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = b + "ms"
}
}); // 第二种方法, 实现第二张图效果
var mySwiper = new Swiper(".swiper-container", {
        slidesPerView: "auto",
        loop: true,
        centeredSlides: !0,
        watchSlidesProgress: !0,
        pagination: ".swiper-pagination",
        paginationClickable: !0,
        onProgress: function (a) {
          var b, c, d; for (b = 0; b < a.slides.length; b++)c = a.slides[b], d = c.progress, scale = 1 - Math.min(Math.abs(.2 * d), 1), es = c.style, es.opacity = 1 - Math.min(Math.abs(d / 2), 1), es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = "translate3d(0px,0," + -Math.abs(150 * d) + "px)"
        },
        onSetTransition: function (a, b) {
          for (var c = 0; c < a.slides.length; c++)es = a.slides[c].style, es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = b + "ms"        }
      });
}
}
};
</script> <style lang="scss" scoped>
@import "../../../static/swiper-slide.min.css"; .onlyShow {
.swiperAll {
.swiper-container {
position: absolute;
bottom: 2.306667rem /* 98/75 */;
top: 1.386667rem /* 104/75 */;
.main-img {
background-position: center;
background-size: cover;
height: 93%;
border-radius: 0.133333rem /* 10/75 */;
box-shadow: 0px 2px 3px #eae7e7;
}
}
}
}
</style>

5.实现效果是这样的

第一张图

第二张图

轮播模仿臭美APP,vue,swiper的更多相关文章

  1. 轮播图模块(vue)

    轮播图模块(vue) 通过属性方式传值 值为一个数组.每一项含有imgUrl(图片地址).link(跳转链接),link为可选属性 <template> <div class=&qu ...

  2. 原生js写一个无缝轮播图插件(支持vue)

    轮播图插件(Broadcast.js) 前言:写这个插件的原因 前段时间准备用vue加上网易云的nodejs接口,模拟网易云音乐移动端.因为想自己写一遍所有的代码以及加固自己的flex布局,所以没有使 ...

  3. vue移动音乐app开发学习(三):轮播图组件的开发

    本系列文章是为了记录学习中的知识点,便于后期自己观看.如果有需要的同学请登录慕课网,找到Vue 2.0 高级实战-开发移动端音乐WebApp进行观看,传送门. 完成后的页面状态以及项目结构如下: 一: ...

  4. 模仿东京首页banner轮播,京东新闻上下滚动动画实现(动画实现)

    接着上篇 微信小程序-阅读小程序demo写:http://www.cnblogs.com/muyixiaoguang/p/5917986.html 首页banner动画实现 京东新闻上下动画实现 想着 ...

  5. 视频swiper轮播

    关于本次文章的内容,实际上是咪咕阅读详情页中的一个前端需求要做的效果,不过比起原需求,此次案例已经被删减掉许多部分了.音频部分舍弃,调用客户端接口舍弃,并做一些整理.最后留下的是这个精简版的案例.方便 ...

  6. angularjs中使用轮播图指令swiper

    我们在angualrjs移动开发中遇到轮播图的功能 安装 swiper  npm install --save swiper   或者 bower install --save swiper 引入文件 ...

  7. 多组图自动无限循环(swiper轮播)

    前两天的一个项目中遇到多组图片无限轮播,当时采用了swiper 但是没有解决让它无限轮播.今天再次尝试了一下发现是自己的样式写错了.今天在这里写一下,为了给自己一个警醒不要犯同样的错误 首先先引入一下 ...

  8. 非常优秀的swiper插件————幻灯片播放、图片轮播

    http://www.idangero.us/ http://www.swiper.com.cn/ Swiper中文网 2015-10-15 SuperSlide2: (这是个PC用的滚屏插件,看着不 ...

  9. swiper,一个页面使用多个轮播

    代码示例: <html> <head> <link href="https://cdn.bootcss.com/Swiper/4.3.0/css/swiper. ...

随机推荐

  1. ubuntu Ifconfig只显示一个lo

    第一步启动网卡 是网卡未启动 命令: ifconfig -a,显示所有网络接口的信息. ifconfig显示当前激活的网络接口信息 ifconfig eth0 up 启动网卡 ifconfig -a ...

  2. 关于springMVC中的路径问题

    相对路径中,我们最后想要的到的是绝对路径,而绝对路径=参照路径+相对路径: 相对路径往往都知道,只需要区分参照路径即可:对于前台和后台,参照路径不太相同: 什么是前台,后台路径: 前台路径: 出现在 ...

  3. C# 静态方法中获取类的名称

    静态方法中用: string className = System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName; 非 ...

  4. JavaWeb第一天--HTML

    HTML HTML简介 HTML(Hyper TextMarkupLanguage) 超文本标记语言. 超文本: 超越了文本仅仅展示信息的功能范畴,泛指:图片.有样式的文字.超链接. 标记: 标签. ...

  5. jQuery的内部运行机制和原理

    jQuery的优点: jQuery是一个非常优秀的JavaScript库,与Prototype,YUI,Mootools等众多的Js类库相比,它剑走偏锋,从Web开发实用的角度出发,抛除了其它Lib中 ...

  6. 汽配生产的精益化管理如何实现?这家3000人的企业靠MES系统进行管理

    精益达电子事业部电子车间于在完成车间改造后,生产能力得到大幅提升.但生产制造过程信息化仍处于空白,众多设备处于单机工作模式,车间现场计划排产.物料管理.质量管理等,还处于原始的凭经验.人工干预方式. ...

  7. (05节)快速搭建SSM项目

    1.1  快速搭建Web项目 注意点:name:archetypeCatalog,value:internal 原因:Intellij IDEA根据maven archetype的本质,执行mvn a ...

  8. Tensorcore使用方法

    用于深度学习的自动混合精度 深度神经网络训练传统上依赖IEEE单精度格式,但在混合精度的情况下,可以训练半精度,同时保持单精度网络的精度.这种同时使用单精度和半精度表示的技术称为混合精度技术. ​混合 ...

  9. php组合设计模式(composite pattern)

    过十点. <?php /* The composite pattern is about treating the hierarchy of objects as a single object ...

  10. Vue工程化之引入element-ui框架后图标失效

    场景: vue-cli搭建的工程化项目,引入element框架后发现图标无效,变为方块 解决方案: 在index.html引入样式文件CDN链接即可 <!-- 引入样式 --> <l ...