本篇文章給大家分享的是有關(guān)使用vueJs怎么實現(xiàn)一個圖片輪播功能,小編覺得挺實用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
carousel.vue
<template> <div ref="root"> <div class="sliderPanel"> <div v-for="(item,index) in imgArray" class="verticalCenter picbox"> <transition name="slide-fade"> <img : @mouseover="clearAuto" @mouseout="slideAuto" v-show="index===selectIndex" :src="item.url" > </transition> </div> </div> <div @click="clickLeft" @mouseover="clearAuto" @mouseout="slideAuto" class="arrowLeft verticalCenter horizaCenter"> 左移 </div> <div @click="clickRight" @mouseover="clearAuto" @mouseout="slideAuto" class="arrowRight verticalCenter horizaCenter"> 右移 </div> <div class="sliderBar horizaCenter"> <div v-for="(item,index) in imgArray" @mouseover="clearAuto" @mouseout="slideAuto" @click="setIndex(index)" class="circle" :class="{circleSelected:index===selectIndex}"> </div> </div> </div> </template> <script> const SCREEN_WIDTH=document.body.clientWidth//網(wǎng)頁可見區(qū)域?qū)?nbsp; const SCREEN_HEIGHT=document.body.scrollHeight//網(wǎng)頁正文全文高 var selectIndex=0 var timer=null export default { name: "ErCarousel", data() { return { selectIndex:0, width:'100%', height:SCREEN_HEIGHT+'px', top:0, imgArray:[ { url:'/src/components/carousel/image/1.jpg', }, { url:'/src/components/carousel/image/2.jpg', }, { url:'/src/components/carousel/image/3.jpg', } ] } }, methods:{ slideAuto:function () { var that=this; timer=setInterval(function(){ that.clickRight(); },3000) //clearInterval(timer); }, clearAuto:function(){ clearInterval(timer); }, clickLeft:function(){ if(this.selectIndex==0){ this.selectIndex=this.imgArray.length-1; }else{ this.selectIndex--; } console.log(this.selectIndex); }, clickRight:function(){ if(this.selectIndex==this.imgArray.length-1){ this.selectIndex=0; }else{ this.selectIndex++; } }, setIndex:function (index) { this.selectIndex=index; } }, mounted:function(){ this.slideAuto(); } } </script> <style>
以上就是使用vueJs怎么實現(xiàn)一個圖片輪播功能,小編相信有部分知識點(diǎn)可能是我們?nèi)粘9ぷ鲿姷交蛴玫降?。希望你能通過這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司行業(yè)資訊頻道。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站jinyejixie.com,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
當(dāng)前名稱:使用vueJs怎么實現(xiàn)一個圖片輪播功能-創(chuàng)新互聯(lián)
分享網(wǎng)址:http://jinyejixie.com/article42/diciec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、營銷型網(wǎng)站建設(shè)、定制網(wǎng)站、面包屑導(dǎo)航、微信小程序、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容