最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue+swiper實(shí)現(xiàn)側(cè)滑菜單效果

 更新時(shí)間:2017年12月28日 11:27:01   作者:martsforever  
這篇文章主要為大家詳細(xì)介紹了vue+swiper實(shí)現(xiàn)側(cè)滑菜單效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue swiper實(shí)現(xiàn)側(cè)滑菜單效果的具體代碼,供大家參考,具體內(nèi)容如下

先上效果圖:

這個(gè)左右滑動(dòng)以及上下滑動(dòng)主要使用了Swiper的輪播功能,首先是該自定義組件的代碼:

<template> 
 <div class="s-slider"> 
 <swiper :options="horizontalSwiperOptions" ref="horizontalSwiper"> 
  <swiper-slide class="left" ref="left" v-bind:style="{'background':getRandomColor()}"> 
  <slot name="left"></slot> 
  </swiper-slide> 
  <swiper-slide class="content"> 
  <swiper :options="verticalSwiperOptions" ref="verticalSwiper"> 
   <swiper-slide class="top" ref="top" v-bind:style="{'background':getRandomColor()}"> 
   <slot name="top"></slot> 
   </swiper-slide> 
   <swiper-slide class="content" ref="content" v-bind:style="{'background':getRandomColor()}"> 
   <slot name="content"></slot> 
   </swiper-slide> 
   <swiper-slide class="bottom" ref="bottom" v-bind:style="{'background':getRandomColor()}"> 
   <slot name="bottom"></slot> 
   </swiper-slide> 
  </swiper> 
  </swiper-slide> 
  <swiper-slide class="right" ref="right" v-bind:style="{'background':getRandomColor()}"> 
  <slot name="right"></slot> 
  </swiper-slide> 
 </swiper> 
 </div> 
</template> 
<script> 
 import {swiper, swiperSlide, swiperWraper} from 'vue-awesome-swiper' 
 export default { 
 name: "s-slider", 
 props: ['leftWidth','rightWidth','topHeight','bottomHeight'], 
 data() { 
  return { 
  horizontalSwiperOptions: { 
   slidesPerView: 'auto', 
   initialSlide: 0, 
   direction: 'horizontal' 
  }, 
  verticalSwiperOptions:{ 
   slidesPerView: 'auto', 
   initialSlide: 0, 
   direction: 'vertical' 
  } 
  } 
 }, 
 mounted() { 
  setTimeout(() => { 
  this._initMenuWidth(); 
  }, 20); 
 
 }, 
 methods: { 
  _initMenuWidth() { 
  this.$refs.left.$el.style.width = this.leftWidth; 
  this.$refs.right.$el.style.width = this.rightWidth; 
  this.$refs.top.$el.style.height = this.topHeight; 
  this.$refs.bottom.$el.style.height = this.bottomHeight; 
  this.horizontalSwiper.updateSlides(); 
  this.horizontalSwiper.slideTo(1, 1000, false); 
  this.verticalSwiper.updateSlides(); 
  this.verticalSwiper.slideTo(1, 1000, false); 
  }, 
  /*獲取隨機(jī)顏色*/ 
  getRandomColor() { 
  return "#" + ("00000" + ((Math.random() * 16777215 + 0.5) >> 0).toString(16)).slice(-6); 
  } 
 }, 
 computed: { 
  horizontalSwiper() { 
  return this.$refs.horizontalSwiper.swiper; 
  }, 
  verticalSwiper(){ 
  return this.$refs.verticalSwiper.swiper; 
  } 
 } 
 } 
</script> 
 
<style scoped lang="scss"> 
 @import "src/base/css/public/variable.scss"; 
 @import "swiper/dist/css/swiper.css"; 
 
 .s-slider { 
 height: 100%; 
 color: white; 
 .swiper-container { 
  @include fill-with-parent 
 } 
 } 
</style> 

 該組件自定義了四個(gè)屬性,分別是左右側(cè)滑菜單的寬度,上下滑動(dòng)菜單的高度,leftWdith、rightWidth、topHeight、bottomHeight,然后用了一個(gè)橫向的輪播用來(lái)存放左滑菜單,中間內(nèi)容,右滑菜單,然后在中間內(nèi)容又放了一個(gè)縱向的輪播用來(lái)放置上滑菜單,內(nèi)容以及下滑菜單,具體思路就是這樣。在組件掛載的時(shí)候,需要根據(jù)父組件傳入的數(shù)值去初始化四個(gè)菜單的寬高,初始化完畢寬高之后,還要調(diào)用swiper本身的updateSlides更新所有的slides,不然滑動(dòng)的時(shí)候,還是按照沒設(shè)置之前的寬高進(jìn)行滑動(dòng)。在父組件中調(diào)用:

<s-slider leftWidth="200px" rightWidth="300px" topHeight="100px" bottomHeight="150px"> 
  <div slot="left"> 
  left 
  </div> 
  <div slot="content"> 
  Content 
  </div> 
  <div slot="right"> 
  right 
  </div> 
  <div slot="top"> 
  top 
  </div> 
  <div slot="bottom"> 
  bottom 
  </div> 
 </s-slider> 

不要忘了在父組件中還要引入這個(gè)vue組件。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue遞歸生成樹狀結(jié)構(gòu)的示例代碼

    vue遞歸生成樹狀結(jié)構(gòu)的示例代碼

    這篇文章主要介紹了vue遞歸生成樹狀結(jié)構(gòu)的示例,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2024-07-07
  • Vue 自定義組件 v-model 使用詳解

    Vue 自定義組件 v-model 使用詳解

    這篇文章主要介紹了Vue 自定義組件 v-model 使用介紹,包括vue2中使用和vue3中使用,本文通過示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-08-08
  • vue中插槽(slot)幾種類型的使用方法

    vue中插槽(slot)幾種類型的使用方法

    本文主要介紹了vue中插槽(slot)幾種類型的使用方法,主要分三種,默認(rèn)插槽,具名插槽,作用域插槽,下面就來(lái)一起介紹一下,感興趣的可以了解一下
    2024-03-03
  • Vue中的數(shù)據(jù)驅(qū)動(dòng)解釋

    Vue中的數(shù)據(jù)驅(qū)動(dòng)解釋

    這篇文章主要為大家介紹了Vue中的數(shù)據(jù)驅(qū)動(dòng)解釋,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-12-12
  • vue中css如何使用data中的變量

    vue中css如何使用data中的變量

    這篇文章主要介紹了vue中css如何使用data中的變量問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • Vue項(xiàng)目中new?Vue()和export?default{}的區(qū)別說明

    Vue項(xiàng)目中new?Vue()和export?default{}的區(qū)別說明

    這篇文章主要介紹了Vue項(xiàng)目中new?Vue()和export?default{}的區(qū)別說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • vue中beforeRouteLeave實(shí)現(xiàn)頁(yè)面回退不刷新的示例代碼

    vue中beforeRouteLeave實(shí)現(xiàn)頁(yè)面回退不刷新的示例代碼

    這篇文章主要介紹了vue中beforeRouteLeave實(shí)現(xiàn)頁(yè)面回退不刷新的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • 快速入門Vue

    快速入門Vue

    本篇文章主要介紹了如何快速入門Vue的方法,對(duì)0基礎(chǔ)學(xué)習(xí)Vue的朋友會(huì)很有幫助,跟著小編一起來(lái)看下吧
    2016-12-12
  • vue按需加載組件webpack require.ensure的方法

    vue按需加載組件webpack require.ensure的方法

    本篇文章主要介紹了vue按需加載組件webpack require.ensure的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • VUE項(xiàng)目中調(diào)用高德地圖的全流程講解

    VUE項(xiàng)目中調(diào)用高德地圖的全流程講解

    這篇文章主要介紹了VUE項(xiàng)目中調(diào)用高德地圖的全流程講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08

最新評(píng)論

郎溪县| 游戏| 临汾市| 望都县| 衡阳县| 中阳县| 白城市| 丰顺县| 江城| 榆树市| 宝坻区| 嘉定区| 郸城县| 龙陵县| 伊宁市| 万荣县| 安塞县| 邢台市| 洪雅县| 闸北区| 年辖:市辖区| 周宁县| 耒阳市| 淳安县| 杭锦旗| 贞丰县| 保亭| 库尔勒市| 新巴尔虎右旗| 石屏县| 尼玛县| 龙胜| 台东市| 株洲市| 灯塔市| 仪征市| 金昌市| 池州市| 平舆县| 博爱县| 湘西|