用vue 實現(xiàn)手機觸屏滑動功能
功能:iview Carousel 走馬燈,我需要在phone上實現(xiàn)滑動切換功能。
<div @touchstart='phone_mouseS' @touchend='phone_mouseE'><Carousel :autoplay-speed='5000' v-model='phone_mouseMIndex' autoplay :value='0' loop v-if='menuChoose == ’/’'> <CarouselItem> <img src='http://m.b3g6.com/static/common/phone_banner_index1.jpg' /> </CarouselItem> <CarouselItem> <img src='http://m.b3g6.com/static/common/phone_banner_index1.jpg' /> </CarouselItem> <CarouselItem> <img src='http://m.b3g6.com/static/common/phone_banner_index3.jpg' /> </CarouselItem></Carousel></div>
data() {return { phone_mouseMIndex: 0, // phone端 滑動索引 phone_mouseMX0: 0, // phone端 滑動索引 phone_mouseMX1: 0, // phone端 滑動索引}},...// phone端 滑動開始phone_mouseS(e){ this.phone_mouseMX0 = e.changedTouches[0].pageX;},// phone端 滑動結束phone_mouseE(e){ this.phone_mouseMX1 = e.changedTouches[0].pageX; let tag = this.phone_mouseMX1 - this.phone_mouseMX0; if(tag >= 50){ if(this.phone_mouseMIndex > 0){ this.phone_mouseMIndex--; }else{ this.phone_mouseMIndex = 2; } } if(tag <= -50){ if(this.phone_mouseMIndex < 2){ this.phone_mouseMIndex++; }else{ this.phone_mouseMIndex = 0; } }}
到此這篇關于用vue 實現(xiàn)手機觸屏滑動功能的文章就介紹到這了,更多相關vue 手機觸屏滑動內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持好吧啦網(wǎng)!
相關文章:
1. ASP基礎知識Command對象講解2. JavaScript實現(xiàn)留言板實戰(zhàn)案例3. 如何從Python的cmd中獲得.py文件參數(shù)4. Python-openpyxl表格讀取寫入的案例詳解5. 如何在python中執(zhí)行另一個py文件6. windows下java -jar 后臺運行以及殺死后臺進程的操作7. 實現(xiàn)java簡單的線程池8. vscode運行php報錯php?not?found解決辦法9. 使用Blazor框架實現(xiàn)在前端瀏覽器中導入和導出Excel10. 資深程序員:給Python軟件開發(fā)測試的25個忠告!

網(wǎng)公網(wǎng)安備