vue2移動(dòng)端+swiper實(shí)現(xiàn)異形的slide方式
在Vue2中安裝及使用Swiper
安裝swiper
npm install swiper@4.5.1 --save-dev
在main.js中引入
import 'swiper/dist/css/swiper.min.css'; import 'swiper/dist/js/swiper.min';
實(shí)現(xiàn)代碼
以下分別是html、數(shù)據(jù)+swiper設(shè)置、樣式的代碼:
<template> <!-- 輪播圖 --> <div class="swiper" id="swiper1"> <div class="swiper-wrapper"> <div class="swiper-slide" v-for="(item, index) in bookSwiper" :key="index"> <img :src="item.img" class="bookImg" /> </div> </div> </div> </template>
<script> import Swiper from 'swiper'; export default { name: "HomeView", data() { return { bookSwiper: [ { img: "http://img.test.o2ting.com/ProductImages/2018/-0/20180206155502_726R.jpg_355x473.jpg", cntname: "錯(cuò)嫁良緣之一代軍師", }, { img: "http://iread.wo.com.cn/res/images/cover/lhsz/1491552645683/stream/smlf/image/cover.jpg", cntname: "鬼墓迷燈", }, { img: "http://pic.qingting.fm/2017/0228/20170228173809513.jpg!medium", cntname: "九霄靈帝", }, ], }; }, mounted() { new Swiper("#swiper1", { direction: "horizontal", speed: 600, loop: true, autoplay: false, observer: true, observeParents: true, effect: "coverflow", slidesPerView: "auto", centeredSlides: true, coverflowEffect: { rotate: 0, //slide做3d旋轉(zhuǎn)時(shí)Y軸的旋轉(zhuǎn)角度。默認(rèn)50。 stretch: -5, //每個(gè)slide之間的拉伸值,越大slide靠得越緊。 默認(rèn)0。 depth: 20, //slide的位置深度。值越大z軸距離越遠(yuǎn),看起來(lái)越小。 默認(rèn)100。 modifier: 5, slideShadows: false, //開(kāi)啟slide陰影。默認(rèn) true。 }, }); }, }; </script>
// 輪播圖 .swiper { width: 100%; margin-bottom: 20px; .swiper-slide { width: 335px !important; height: 120px; font-size: 14px; text-align: center; line-height: 80px; border-radius: 8px; position: relative; } .bookImg { width: 335px !important; height: 120px; border-radius: 8px; } }
實(shí)現(xiàn)效果
效果圖如下:
效果類(lèi)似:
Swiper演示中的“實(shí)現(xiàn)異形的slide”
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
ant design vue導(dǎo)航菜單與路由配置操作
這篇文章主要介紹了ant design vue導(dǎo)航菜單與路由配置操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-10-10Vue.js設(shè)計(jì)與實(shí)現(xiàn)分支切換與清除學(xué)習(xí)總結(jié)
這篇文章主要為大家介紹了Vue.js設(shè)計(jì)與實(shí)現(xiàn)分支切換與清除學(xué)習(xí)總結(jié),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05詳解如何在Vue項(xiàng)目中導(dǎo)出Excel
這篇文章主要介紹了如何在Vue項(xiàng)目中導(dǎo)出Excel,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04uni-app中vue3表單校驗(yàn)失敗的問(wèn)題及解決方法
最近遇到這樣的問(wèn)題在app中使用uni-forms表單,并添加校驗(yàn)規(guī)則,問(wèn)題是即使輸入內(nèi)容,表單校驗(yàn)依然失敗,本文給大家分享uni-app中vue3表單校驗(yàn)失敗的問(wèn)題及解決方法,感興趣的朋友一起看看吧2023-12-12vue v-viewer組件使用示例詳解(v-viewer輪播圖)
這篇文章主要介紹了vue v-viewer組件使用示例詳解(v-viewer輪播圖),本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-02-02element?UI中el-dialog實(shí)現(xiàn)拖拽功能示例代碼
我們?cè)陂_(kāi)發(fā)中常會(huì)遇見(jiàn)拖拽的功能,下面這篇文章主要給大家介紹了關(guān)于element?UI中el-dialog實(shí)現(xiàn)拖拽功能的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-12-12