国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

實現(xiàn)swiper 3d 輪播效果

這篇具有很好參考價值的文章主要介紹了實現(xiàn)swiper 3d 輪播效果。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

先上個效果圖,代碼可以直接拿~
swiper 3d,前端

安裝swiper和vue-awesome-swiper

因為項目用的是nuxt2,所以考慮到swiper的兼容問題,選擇的是"swiper": “^5.2.0”

首先是安裝swiper和vue-awesome-swiper,并指定版本

npm install swiper@5.2.0 --save

npm install vue-awesome-swiper@4.1.1 --save

然后引入,在nuxt.config.js中引入

css: [
    'swiper/css/swiper.css'
],
plugins: [
    { src: '@/plugins/vue-swiper', ssr: false }
],

基本用法

在plugins下新建一個vue-swiper.js

import Vue from 'vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'
Vue.use(VueAwesomeSwiper)

在components下新建一個VueSwiper.vue

<template>
  <div v-if="initStatus" v-swiper:mySwiper="swiperOption" class="swiper mySwiper swiperBox">
    <div class="swiper-wrapper">
      <div class="swiper-slide" v-for="(item, index) in list.value" :key="index">
        <div class="pr">
          <div class="swiper-slide-imgbox uf uf-ac uf-jc">
            <img :src="item.imageUrl" />
          </div>
          <div class="font12 c8 txt-box">{{ item.title }}</div>
        </div>
      </div>
    </div>
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>
  </div>
</template>
<script>
export default {
  props: {
    list: {//banner數(shù)組
      type: Object,
      default: function () {
        return {}
      }
    },
    slidesPerView: {//一頁顯示幾個
      type: Number,
      default: 1
    }
  },
  data() {
    return {
      initStatus: false,//初始化狀態(tài)
      swiperOption: {},//swiper參數(shù)
    }
  },
  mounted() {
    let self = this;
    this.$nextTick(() => {
      this.swiperOption = {
        loop: true,
        loopAdditionalSlides: 3,
        coverflowEffect: {
          rotate: 60, //側(cè)轉(zhuǎn)角度(正值凹陷)
          stretch: -80,//每個slide之間拉伸值(正值緊貼)
          depth: 100,  //值越大為遠景(可負值)
          modifier: 1, //depth和rotate和stretch的倍率
          shadows: false
       },
        centeredSlides: true,
        initialSlide: 1,
        slidesPerView: self.slidesPerView,//一頁顯示幾個
        spaceBetween: 10,//間隔
        updateOnWindowResize: true,
        watchSlidesProgress: true,//
        noSwiping: true,//
        effect: 'coverflow', //設(shè)置Slide的切換效果,默認為"slide"(普通位移切換),還可設(shè)置為"fade"(淡入)、"cube"(方塊)、"coverflow"(3d流)、"flip"(3d翻轉(zhuǎn))、"cards"(卡片式)、"creative"(創(chuàng)意性)。
        freeMode: 1,
        autoplay: {//自動輪播//
          delay: 3000, //
          disableOnInteraction: false,//操作swiper后 自動輪播不會停止//
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        },
      }
      this.initStatus = true //渲染swiper
    })
  },
}
</script>
<style lang="scss" scoped>
.swiper {
  margin-left: auto;
  margin-right: auto;
  position: relative;
  box-sizing: border-box;
}
.swiper-wraper {
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  box-sizing: content-box;
}
.swiper-slide {
  flex-shrink: 0;
  width: 100%;
  height: 100%;
}
.swiper-slide-imgbox{
  width: 315px;
  height: 302px;
  opacity: 1;
  background: rgba(255, 255, 255, 1);
  padding: 20px;
  box-sizing: border-box;
}
.pr{
  position: relative;
}
.txt-box{
  position: absolute;
  bottom: -40px;
  left: 0;
  right: 0;
  margin: 0 auto;
}
</style>

在plugins下引入

// 引入vue 及 組件
import Vue from 'vue'
import VueSwiper from '@/components/VueSwiper'

// 全局注冊組件
Vue.component('VueSwiper', VueSwiper)

然后是使用這個組件,在pages下新建一個honor.vue

<template>
  <div class="main-container">
    <PageHeader />

    <!-- banner -->
    <div class="banner-box">
      <div class="font48 weight700 c3">資質(zhì)與榮譽</div>
      <div class="font16 weight400 c7 op7 mt30">Qualifications and Honors</div>
    </div>

    <div class="content-box" v-for="(honorItem, index) in honorTypes" :key="index">
      <div class="font36 pt100 mb40 vc" v-if="honorInfo[index] && honorInfo[index].value && honorInfo[index].value.length">{{ honorItem.title }}</div>
      <div class="review-content" v-if="honorInfo[index] && honorInfo[index].value && honorInfo[index].value.length">
        <vue-swiper :list="honorInfo[index]" :slidesPerView="3"></vue-swiper>
      </div>
    </div>

    <PageFooter />
  </div>
</template>

<script>
import { shareToWechat } from "../../utils/format";
export default {
  name: "Honor",

  data() {
    return {
      showType: "honor",
      honorTypes: [],
      honors: [],
      honorInfo: []
    };
  },

  methods:{
    async findHonorTypeData() {
      let _params = {
        order: 'sort'
      }
      this.loading = true;
      const res = await this.$axios.$get("/certType", { params: _params });
      this.loading = false;
      let _this = this
      if (res && res.status === 0) {
        this.honorTypes = res.result
        res.result.forEach((item, i) => {
          _this.findHonorsData(item.title)
        })
      } else {
        this.$message.error(res.message);
      }
    },

    async findHonorsData(certType) {
      let _params = {
        order: 'sort',
        certType: certType,
        pageNum: 1,
        pageSize: 30
      }
      this.loading = true;
      const res = await this.$axios.$get("/certList", { params: _params });
      this.loading = false;
      let _this = this
      if (res && res.status === 0) {
        res.result.rows.forEach((item, i) => {
          item.imageUrl = `/images${item.imageUrl}`
        })
        let _obj = {
          name: certType,
          value: res.result.rows
        }
        _this.honorInfo.push(_obj)
      } else {
        this.$message.error(res.message);
      }
    },
  },

  mounted () {
    this.findHonorTypeData()
  }
};
</script>

<style lang="scss" scoped>
.content-box{
  background-color: rgba(239, 241, 244, 1);
  padding-bottom: 100px;
}
.review-content {
  width: 100%;
  height: 302px;
  position: relative;
  margin: 0 auto;
  .swiperBox {
    height: 360px;
    width: 100%;
    position: static;
    padding-top: 20px;
    & /deep/ {
      .swiper-slide {
        text-align: center;
        font-size: 18px;
        background: #fff;
        width: 315px !important;
        height: 302px;/* Center slide text vertically */
        display: -webkit-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: center;
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-box-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
        transition-property: all;
        img {
          max-width: 295px;
          height: auto;
          max-height: 282px;
          border-radius: 2px;
        }
        .swiper-slide-shadow-left{
          background-image: none
        }
        .swiper-slide-shadow-right{
          background-image: none
        }
      }
      .swiper-slide-active {
        .mask {
          display: none;
        }
      }
      .swiper-button-prev,.swiper-button-next {
        position: absolute;
        width: 34px;
        height: 64px;
        line-height: 64px;
        border-radius: 6px;
        font-size:30px;
        color: #00A2FF;
        top: 50%;
      }
      .swiper-button-prev:after,.swiper-button-next:after {
        font-size: 30px;
        &:hover{
          background-color: none;
        }
      }
      .swiper-button-prev {
        left: 0px;
      }
      .swiper-button-next {
        right: 0px;
      }
      .swiper-button-prev:hover,.swiper-button-next:hover {
        background: rgba(209, 209, 209, 0.5);
        color: rgba(255, 255, 255, 0.5);
      }
    }
  }
}
.banner-box {
  height: 370px;
  opacity: 1;
  padding: 172px 120px 0 120px;
  box-sizing: border-box;
  background: url(/images/productImages/honor.png) right 120px bottom 20px / 320px auto no-repeat,linear-gradient(90deg, rgba(137, 247, 254, 1) 0%, rgba(84, 156, 252, 1) 100%);;
}
.honor-box {
  max-width: 990px;
  padding-bottom: 82px;
  margin: 0 auto;
  & .honor-card {
    width: 300px;
    margin: 0 15px 48px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.16);
    border-radius: 4px;
    background-clip: content-box;
    background-color: rgba(255, 255, 255, 1);
    background-position: center center;
    background-size: 100% auto;
    background-repeat: no-repeat;
    &.large {
      padding: 32px;
    }
    &.small {
      padding: 19px 15px;
    }
  }
}
@media screen and (max-width: 768px) {
  .banner-box {
    height: 260px;
    background-position: center top 100px, left top;
    background-size: auto 80px, auto 100%;
    & .banner-content {
      top: 260px;
      width: 100%;
    }
  }
  .honor-box {
    justify-content: center;
    padding: 0 30px 20px;
    & .honor-card {
      width: 300px;
      margin: 0 15px 20px;
    }
  }
}
</style>

出現(xiàn)空白頁的bug

使用了swiper的coverflowEffect效果,設(shè)置了同時顯示3個,同時開啟了loop模式。

當切換到倒數(shù)第二張時沒有新的slider生成,導致最后一張的右邊是空白的,只有切換到最后一張時才會再在后面復(fù)制新的slider,怎么讓它在顯示倒數(shù)第二張時就生成新的slider?

swiper 3d,前端

最后發(fā)現(xiàn)slidesPerView設(shè)置為auto,就正常了

然后調(diào)整coverflowEffect里的stretch和depth來弄就沒問題了

VueSwiper.vue文章來源地址http://www.zghlxwxcb.cn/news/detail-854468.html

<template>
  <div v-if="initStatus" v-swiper:mySwiper="swiperOption" class="swiper mySwiper swiperBox">
    <div class="swiper-wrapper">
      <div class="swiper-slide" v-for="(item, index) in list.value" :key="index">
        <div class="pr">
          <div class="swiper-slide-imgbox uf uf-ac uf-jc">
            <img :src="item.imageUrl" />
          </div>
          <div class="font12 c8 txt-box">{{ item.title }}</div>
        </div>
      </div>
    </div>
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>
  </div>
</template>
<script>
export default {
  props: {
    list: {//banner數(shù)組
      type: Object,
      default: function () {
        return {}
      }
    }
  },
  data() {
    return {
      initStatus: false,//初始化狀態(tài)
      swiperOption: {},//swiper參數(shù)
    }
  },
  mounted() {
    let self = this;
    this.$nextTick(() => {
      this.swiperOption = {
        loop: true,
        loopAdditionalSlides: 3,
        coverflowEffect: {
          rotate: 50, //側(cè)轉(zhuǎn)角度(正值凹陷)
          stretch: -110,//每個slide之間拉伸值(正值緊貼)
          depth: 100,  //值越大為遠景(可負值)
          modifier: 1, //depth和rotate和stretch的倍率
          shadows: false
       },
        centeredSlides: true,
        initialSlide: 1,
        slidesPerView: 'auto',//一頁顯示幾個
        spaceBetween: 10,//間隔
        updateOnWindowResize: true,
        watchSlidesProgress: true,//
        noSwiping: true,//
        effect: 'coverflow', //設(shè)置Slide的切換效果,默認為"slide"(普通位移切換),還可設(shè)置為"fade"(淡入)、"cube"(方塊)、"coverflow"(3d流)、"flip"(3d翻轉(zhuǎn))、"cards"(卡片式)、"creative"(創(chuàng)意性)。
        freeMode: 1,
        autoplay: {//自動輪播//
          delay: 3000, //
          disableOnInteraction: false,//操作swiper后 自動輪播不會停止//
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        },
      }
      this.initStatus = true //渲染swiper
    })
  },
}
</script>
<style lang="scss" scoped>
.swiper {
  margin-left: auto;
  margin-right: auto;
  position: relative;
  box-sizing: border-box;
}
.swiper-wraper {
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  box-sizing: content-box;
}
.swiper-slide {
  flex-shrink: 0;
  width: 100%;
  height: 100%;
}
.swiper-slide-imgbox{
  width: 315px;
  height: 302px;
  opacity: 1;
  background: rgba(255, 255, 255, 1);
  padding: 20px;
  box-sizing: border-box;
}
.pr{
  position: relative;
}
.txt-box{
  position: absolute;
  bottom: -40px;
  left: 0;
  right: 0;
  margin: 0 auto;
}
</style>

到了這里,關(guān)于實現(xiàn)swiper 3d 輪播效果的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 解決微信小程序swiper輪播圖撐不滿有留白 實現(xiàn)swiper輪播圖撐滿父容器

    解決微信小程序swiper輪播圖撐不滿有留白 實現(xiàn)swiper輪播圖撐滿父容器

    問題 :如下圖,swiper輪播圖兩側(cè)會有留白,沒有撐滿swiper 失敗的嘗試 : 1.調(diào)整圖片尺寸 2.設(shè)屬性設(shè)置image的mode為scaleToFill 3.設(shè)置item的屬性 都沒能實現(xiàn)將圖片填充滿輪播圖,圖片會有右側(cè)和底部兩塊留白 通過調(diào)試器查看到image區(qū)域很小,懷疑是image本身屬性的問題 隨后嘗試在

    2024年04月25日
    瀏覽(103)
  • 使用swiper實現(xiàn)圖片輪播功能

    swiper中文官網(wǎng)地址:在這里 官網(wǎng)介紹:Swiper是純javascript打造的滑動特效插件,面向手機、平板電腦等移動終端。 按照使用方法下載指定版本的swiper文件; 需要用到的文件有swiper-bundle.js和swiper-bundle.css文件,還需要引入map文件,不然會有警告提示; 準備工作: 先將圖片放到

    2024年02月14日
    瀏覽(28)
  • Swiper輪播圖后端接口實現(xiàn)

    2024年01月25日
    瀏覽(18)
  • 微信小程序swiper實現(xiàn)層疊輪播圖

    微信小程序swiper實現(xiàn)層疊輪播圖

    在微信小程序中,需要實現(xiàn)展示5個,橫向?qū)盈B的輪播圖效果,輪播圖由中間到2側(cè)的依次縮小.如下圖 使用原生小程序進行開發(fā),沒有使用Skyline模式,所以layout-type配置項也無效。所以基于swiper組件進行調(diào)整。 主要思路就是設(shè)置不同的樣式,根據(jù)當前激活的項,來動態(tài)切換樣式。

    2024年01月24日
    瀏覽(95)
  • JS常用插件 Swiper插件 實現(xiàn)輪播圖

    JS常用插件 Swiper插件 實現(xiàn)輪播圖

    Swiper 是一款免費以及輕量級的移動設(shè)備觸控滑塊的js框架 中文官網(wǎng)地址: https://www.swiper.com.cn/ 點擊查看 Swiper演示 ,里面的功能和樣式十分豐富,根據(jù)自己的需求選擇 中文教程 中詳細介紹了如何使用Swiper API文檔 中介紹了各個模塊以及參數(shù)的詳細信息,遇到不明白的參數(shù)可以

    2024年02月01日
    瀏覽(85)
  • Vue2+swiper基礎(chǔ)實現(xiàn)輪播圖

    Vue2+swiper基礎(chǔ)實現(xiàn)輪播圖

    提示:文章寫完后,目錄可以自動生成,如何生成可參考右邊的幫助文檔 swiper的基礎(chǔ)使用 提示:以下是本篇文章正文內(nèi)容,下面案例可供參考 Swiper中文網(wǎng)-輪播圖幻燈片js插件,H5頁面前端開發(fā) ? ? ? ? 注意:我們用的是vue2所以推薦大家下載swiper5版本 示例: 查看安裝是否完成

    2024年01月16日
    瀏覽(91)
  • 不到200行用Vue實現(xiàn)類似Swiper.js的輪播組件

    不到200行用Vue實現(xiàn)類似Swiper.js的輪播組件

    大家在開發(fā)過程中,或多或少都會用到輪播圖之類的組件,PC和Mobile上使用 Swiper.js ,小程序上使用swiper組件等。 本文將詳細講解如何用 Vue 一步步實現(xiàn)的類似 Swiper.js 的功能,無任何第三方依賴,干貨滿滿。 在線預(yù)覽:https://zyronon.github.io/douyin/ 項目源代碼:https://github.com/

    2024年04月23日
    瀏覽(24)
  • 小程序swiper一個輪播顯示一個半內(nèi)容且實現(xiàn)無縫滾動
  • 微信小程序首頁、界面布局、3D輪播圖效果(示例二)

    微信小程序首頁、界面布局、3D輪播圖效果(示例二)

    使用swiper實現(xiàn)3D輪播圖效果,自定義頂部狀態(tài)欄,具體代碼: 1、js代碼 2、wxml代碼 3、wxss代碼 4、json代碼 如需要下載完整版,包含監(jiān)聽事件、圖片文件等,請前往下方鏈接,下載完整版,下載后直接使用微信開發(fā)者工具打開即可,下載鏈接為: 小程序完整版界面(示例二)

    2024年02月10日
    瀏覽(27)
  • 創(chuàng)建一個具有背景輪播和3D卡片翻轉(zhuǎn)效果的個人名片網(wǎng)頁

    創(chuàng)建一個具有背景輪播和3D卡片翻轉(zhuǎn)效果的個人名片網(wǎng)頁

    目錄 項目展示 圖片展示 前言 項目目標 項目目標 步驟 3:CSS 樣式 步驟 4:JavaScript 動畫 項目源碼 知識點介紹?(大佬請繞道) HTML 結(jié)構(gòu)的構(gòu)建 2. CSS 樣式的設(shè)計 3. JavaScript 動畫的實現(xiàn) 4. 背景圖輪播的邏輯 5. CSS 3D變換的使用 結(jié)語 項目展示 點擊下面鏈接(第一次打開可能會有

    2024年02月08日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包