轮播模仿臭美APP,vue,swiper
介绍:轮播使用了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的更多相关文章
- 轮播图模块(vue)
轮播图模块(vue) 通过属性方式传值 值为一个数组.每一项含有imgUrl(图片地址).link(跳转链接),link为可选属性 <template> <div class=&qu ...
- 原生js写一个无缝轮播图插件(支持vue)
轮播图插件(Broadcast.js) 前言:写这个插件的原因 前段时间准备用vue加上网易云的nodejs接口,模拟网易云音乐移动端.因为想自己写一遍所有的代码以及加固自己的flex布局,所以没有使 ...
- vue移动音乐app开发学习(三):轮播图组件的开发
本系列文章是为了记录学习中的知识点,便于后期自己观看.如果有需要的同学请登录慕课网,找到Vue 2.0 高级实战-开发移动端音乐WebApp进行观看,传送门. 完成后的页面状态以及项目结构如下: 一: ...
- 模仿东京首页banner轮播,京东新闻上下滚动动画实现(动画实现)
接着上篇 微信小程序-阅读小程序demo写:http://www.cnblogs.com/muyixiaoguang/p/5917986.html 首页banner动画实现 京东新闻上下动画实现 想着 ...
- 视频swiper轮播
关于本次文章的内容,实际上是咪咕阅读详情页中的一个前端需求要做的效果,不过比起原需求,此次案例已经被删减掉许多部分了.音频部分舍弃,调用客户端接口舍弃,并做一些整理.最后留下的是这个精简版的案例.方便 ...
- angularjs中使用轮播图指令swiper
我们在angualrjs移动开发中遇到轮播图的功能 安装 swiper npm install --save swiper 或者 bower install --save swiper 引入文件 ...
- 多组图自动无限循环(swiper轮播)
前两天的一个项目中遇到多组图片无限轮播,当时采用了swiper 但是没有解决让它无限轮播.今天再次尝试了一下发现是自己的样式写错了.今天在这里写一下,为了给自己一个警醒不要犯同样的错误 首先先引入一下 ...
- 非常优秀的swiper插件————幻灯片播放、图片轮播
http://www.idangero.us/ http://www.swiper.com.cn/ Swiper中文网 2015-10-15 SuperSlide2: (这是个PC用的滚屏插件,看着不 ...
- swiper,一个页面使用多个轮播
代码示例: <html> <head> <link href="https://cdn.bootcss.com/Swiper/4.3.0/css/swiper. ...
随机推荐
- C# 创建json传输格式的http请求
public static string PostRequestTest(string content, string url, string contentType = "applicat ...
- [Leetcode] 1120. Maximum Average Subtree
Given the root of a binary tree, find the maximum average value of any subtree of that tree. (A subt ...
- python卸载重新安装,一键安装卸载前的所有安装的第三方插件
好多小可爱都有这样一个困扰,python有了一个大版本的更新,我也想更新,但是安装的好多第三方的库可怎么办呀,更新之后再去一个一个的安装,那可就烦死了. 在这里我来教大家如何快速去安装python更新 ...
- Bootstrap4 glyphicon 移除图标 glyphicon fonts-faces 解决方案
bootrap3是支持的图标 ,4不支持 4已经移除了 收费图标,取而代之建议使用其他的,比如 https://octicons.github.com/ 和http://fontawesome.io/ ...
- MAC电脑下Appium + python3 + robotframework ios的真机测试环境搭建
本人的环境搭建前的准备,MAC电脑一台(macOS Mojave 10.14.0及以上),Xcode 10.0及以上 ,自己注册的一个Apple ID 账户,必须你的电脑能连接互联网,最好不要用公 ...
- English--动词语态
English|动词语态 动词的语态在理解长难句中很重要.了解被动语态与主动语态,掌握语态的变化方式. 前言 目前所有的文章思想格式都是:知识+情感. 知识:对于所有的知识点的描述.力求不含任何的自我 ...
- window 10 npm install node-sass报错
最近准备想用vue-cli初始化一个项目,需要sass-loader编译: 发现window下npm install node-sass和sass-loader一直报错, window 命令行中提示我 ...
- Kafka消费者组静态成员(static consumer member)
Kafka 2.3发布后官网的Consumer参数中增加了一个新的参数:group.instance.id.下面是这个参数的解释: A unique identifier of the consume ...
- MySQL安装和使用
1.MySQL安装: 1).到MySQL官网https://dev.mysql.com/downloads/installer/,下载MySQL 5.7版本:(注:现在官网上最新版本已经变成8.0.1 ...
- 在visual studio中找到属性管理器
方法一: 我们可以在新建的项目中通过视图-->其他窗口-->属性管理器来找到. 这样就能找到属性管理器了. 感谢:https://blog.csdn.net/qq_37939434/art ...