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

vue實現(xiàn)輪播圖片

 更新時間:2022年07月14日 17:02:10   作者:吾行遠方  
這篇文章主要為大家詳細介紹了vue實現(xiàn)簡單的輪播圖片,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了vue實現(xiàn)輪播圖片的具體代碼,供大家參考,具體內(nèi)容如下

1、效果圖

2、案例

<template>
?? ? ? <section class="body">
?? ? ? ? ? <section class="wrap">
?? ? ? ? ? ? ? <swiper :options="swiperOption" class="swiper-wrap" ?ref="mySwiper" v-if="banner.length!=0">
?? ? ? ? ? ? ? ? ? <swiper-slide v-for="(item,index) in banner" :key="index" >
?? ? ? ? ? ? ? ? ? ? ? //點擊圖片跳到哪里,這里跳到home頁面 item舉例:{img:http://www.***.com/home/images/index_img02.png,url:/home}
?? ? ? ? ? ? ? ? ? ? ? <img :src="item.img" alt="" @click="skip_out_page(item.url)" />
?? ? ? ? ? ? ? ? ? </swiper-slide>
?? ? ? ? ? ? ? ? ? <!-- 常見的小圓點 -->
?? ? ? ? ? ? ? ? ? <div class="swiper-pagination" ?v-for="(item,index) in banner" :key="index" slot="pagination" ></div>
?? ? ? ? ? ? ? </swiper>
?? ? ? ? ? </section>
?? ? ? </section>
</template>
<script>
?? ?export default {
?? ? ? ?data() {
?? ? ? ? ? ?const that = this;
?? ? ? ? ? ?return {
?? ? ? ? ? ? ? ?imgIndex: 1,
?? ? ? ? ? ? ? ?swiperOption: {
?? ? ? ? ? ? ? ? ? ?//是一個組件自有屬性,如果notNextTick設(shè)置為true,組件則不會通過NextTick來實例化swiper,也就意味著你可以在第一時間獲取到swiper對象,假如你需要剛加載遍使用獲取swiper對象來做什么事,那么這個屬性一定要是true
?? ? ? ? ? ? ? ? ? ?notNextTick: true,
?? ? ? ? ? ? ? ? ? ?//循環(huán),而不是每次都突然回到第一個
?? ? ? ? ? ? ? ? ? ?loop: true,
?? ? ? ? ? ? ? ? ? ?//設(shè)定初始化時slide的索引,加載頁面時顯示的第幾個,從0開始
?? ? ? ? ? ? ? ? ? ?initialSlide: 0,
?? ? ? ? ? ? ? ? ? ?//自動播放
?? ? ? ? ? ? ? ? ? ?autoplay: {
?? ? ? ? ? ? ? ? ? ? ? ?/*切換輪播圖片的時間,即上次切換成功后到再次需要切換的時間*/
?? ? ? ? ? ? ? ? ? ? ? ?delay: 1500,
?? ? ? ? ? ? ? ? ? ? ? ?stopOnLastSlide: false,
?? ? ? ? ? ? ? ? ? ? ? ?/* 觸摸滑動后是否繼續(xù)輪播 false觸摸后不再點擊繼續(xù)輪播,true觸摸后不再點擊不輪播,停在最后一次頁面*/
?? ? ? ? ? ? ? ? ? ? ? ?disableOnInteraction: false
?? ? ? ? ? ? ? ? ? ?},
?? ? ? ? ? ? ? ? ? ?//滑動速度,時間單位,越小越快,與上面 delay 區(qū)別,speed是完成切換所需時間,delay是切換成功后停留多長時間再切換
?? ? ? ? ? ? ? ? ? ?speed: 800,
?? ? ? ? ? ? ? ? ? ?//滑動方向
?? ? ? ? ? ? ? ? ? ?direction: "horizontal",
?? ? ? ? ? ? ? ? ? ?//小手掌抓取滑動
?? ? ? ? ? ? ? ? ? ?grabCursor: true,
?? ? ? ? ? ? ? ? ? ?on: {
?? ? ? ? ? ? ? ? ? ? ? ?//滑動之后回調(diào)函數(shù)
?? ? ? ? ? ? ? ? ? ? ? ?slideChangeTransitionStart: function() {
?? ? ? ? ? ? ? ? ? ? ? ? ? ?/* realIndex為滾動到當前的slide索引值 */
?? ? ? ? ? ? ? ? ? ? ? ? ? ?that.imgIndex= this.realIndex - 1;
?? ? ? ? ? ? ? ? ? ? ? ?},
?? ? ? ? ? ? ? ? ? ?},
?? ? ? ? ? ? ? ? ? ?//分頁器設(shè)置
?? ? ? ? ? ? ? ? ? ?pagination: {
?? ? ? ? ? ? ? ? ? ? ? ?el: ".swiper-pagination",
?? ? ? ? ? ? ? ? ? ? ? ?clickable: true,
?? ? ? ? ? ? ? ? ? ? ? ?type: "bullets"
?? ? ? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ?},
?? ? ? ? ? ? ? ?banner: []
?? ? ? ? ? ?}
?? ? ? ?},
?? ? ? ?methods: {
?? ? ? ? ? ?skip_out_page(v) {
?? ? ? ? ? ? ? ?window.location.href = v
?? ? ? ? ? ?},
?? ? ? ? ? ?get_data() {
?? ? ? ? ? ? ? ?this.$http.get('test').then(res => {
?? ? ? ? ? ? ? ? ? ?if(res.data.code == '0000'){
?? ? ? ? ? ? ? ? ? ? ? ?this.banner = res.data.img_info
?? ? ? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ?});
?? ? ? ? ? ?}
?? ? ? ?},
?? ? ? ?mounted() {
?? ? ? ? ? ?this.get_data()
?? ? ? ?}
?? ?}
</script>
<style lang="scss">
?? ?.swiper-wrap{
?? ? ? ?width: 100%;
?? ? ? ?height: 210px;
?? ? ? ?background-color: #fff;
?? ?}
?? ?.swiper-pagination{
?? ? ? ?background: #fff;
?? ?}
?? ?.swiper-pagination-bullet{
?? ? ? ?background: #ccc;
?? ? ? ?width: 10px;
?? ? ? ?height: 10px;
?? ? ? ?opacity: 1;
?? ?}
?? ?.swiper-pagination-bullet-active{
?? ? ? ?background: #00C293;
?? ?}
</style>

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

唐河县| 青海省| 阿拉善右旗| 晋宁县| 上思县| 伊宁市| 博湖县| 嫩江县| 安阳市| 诏安县| 富蕴县| 望奎县| 鄄城县| 汨罗市| 唐海县| 顺平县| 聊城市| 蒙城县| 横山县| 保康县| 高尔夫| 锡林浩特市| 军事| 广丰县| 长泰县| 皋兰县| 武邑县| 炉霍县| 新巴尔虎左旗| 大城县| 永吉县| 汪清县| 滦平县| 岳阳县| 香河县| 石渠县| 嘉峪关市| 宜阳县| 平阳县| 吴桥县| 习水县|