亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

如何在VUE中使用vue-awesome-swiper

瀏覽:4日期:2022-10-12 18:12:51
一:首先進入項目目錄中安裝

install vue-awesome-swiper@2.6.7 --save二.使用

全局掛載:

import Vue from ’vue’import VueAwesomeSwiper from ’vue-awesome-swiper’// require stylesimport ’swiper/dist/css/swiper.css’Vue.use(VueAwesomeSwiper, /* { default global options } */)

組件掛載

// require stylesimport ’swiper/dist/css/swiper.css’import { swiper, swiperSlide } from ’vue-awesome-swiper’export default { components: { swiper, swiperSlide }}

新建一個.vue文件,按照以下代碼模式

<template> <div class='index'> <Top navLeft='true' navRight='false'></Top> <div style='padding-top: 1.3rem;padding-left:0.2rem'> <swiper :options='swiperOption' ref='mySwiper' v-if='swiperList.length!=0'> <swiper-slide v-for=’(item,index) of swiperList’ :key=’item.id’ > <img class=’swiper-img’ :src=’item.imgUrl’ alt='門票' @click='swiperClick(index,item.linkUrl)' /> </swiper-slide> <div slot='pagination'></div> </swiper> </div> </div></template><script>import Top from ’@/components/public/Top’;import ’swiper/dist/css/swiper.css’;import { swiper, swiperSlide } from ’vue-awesome-swiper’export default { name: ’Swiper’, components: {Top,swiper,swiperSlide}, data() { return { swiperList:[], swiperOption: { pagination: '.swiper-pagination', initialSlide: 0,//默認第幾張 loop:true, //循環(huán) autoplayDisableOnInteraction:false,//觸摸后再次自動輪播 autoplay:2000, //每張播放時長3秒,自動播放 speed:1000,//滑動速度 } } }, created(){ this.initEvent(); console.log(this.$refs.mySwiper); this.swiperOption.autoplay = this.swiperList.length != 1 ? 2000 : false;//如果是一張圖片不輪播 }, computed: { swiper() { return this.$refs.mySwiper.swiper//組件實例 } }, mounted(){ }, methods: { initEvent:function(){ this.$http.get('http://localhost/swiper') .then(res=>{ this.swiperList=res.data.swiperList; }) .catch(error=>{ console.log(error) }) }, swiperClick:function(index,url){ console.log(index); this.$router.push(url) } }}</script><style scoped>@import '../assets/public/css/bottom.css';@import '../assets/css/index/my.css';#mySwiper >>> .swiper-pagination-bullet { background: #000000;}#mySwiper >>> .swiper-pagination-bullet-active { background: #ff0000;}</style>

頁面展示如下

如何在VUE中使用vue-awesome-swiper

三:在使用過程中遇到的問題

1.觸摸后再次自動輪播問題,添加以下屬性就可以再次輪播

autoplayDisableOnInteraction:false

2.樣式穿透問題,修改圓點的樣式問題

解決方案是給swiper容器添加上ID,然后再在后面添加>>>,這樣就可以解決了

#mySwiper >>> .swiper-pagination-bullet { background: #000000;}#mySwiper >>> .swiper-pagination-bullet-active { background: #ff0000;}

3.解決如果只有一張圖片不輪播問題

以上就是如何在VUE中使用vue-awesome-swiper的詳細內(nèi)容,更多關(guān)于VUE中使用vue-awesome-swiper的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 日本成人片网站 | 亚洲 欧美 中文 日韩欧美 | 欧美大黄视频 | 鲁丝一区二区三区不属 | 欧美国产成人精品一区二区三区 | 欧美在线黄色片 | 最新国产一区二区精品久久 | 色爱区综合激月婷婷激情五月 | 久久精品国产99国产精品免费看 | 国产这里有精品 | 亚洲第一色站 | 国产高清在线91福利 | 国模私拍福利视频在线透漏 | 青青在线香蕉精品视频免费看 | 黄色在线视频观看 | 伊人99在线观看 | 亚洲精品第一 | 欧美精品在线一区二区三区 | 成人网视频免费播放 | 男女交性高清全过程无遮挡 | 91在线视频播放 | 精品日韩一区二区 | 福利在线一区 | 国内国产真实露脸对白 | 日本亚洲中午字幕乱码 | 亚洲 国产 日韩 欧美 | 2021中国大陆精品视频xxxx | 国产精品一区二区久久精品涩爱 | 国产伦理久久精品久久久久 | 久久九色综合九色99伊人 | 99热这里只有精品国产免费 | 亚洲一区2区三区4区5区 | 精品久久香蕉国产线看观看亚洲 | 国产人成亚洲第一网站在线播放 | 国内精品自在欧美一区 | 91网视频在线观看 | 日韩成人中文字幕 | 国产免费人人看大香伊 | 在线高清免费爱做网 | 99久久免费中文字幕精品 | 久久久久亚洲精品美女 |