Vue移動端左滑右滑


使用的組件地址:https://github.com/vuejs/vue-touch/tree/next

注:vue2.0以上

1、安裝

npm install vue-touch@next --save

 

2、main.js中引入  

import VueTouch from 'vue-touch'

Vue.use(VueTouch, {name: 'v-touch'});

 

3、在使用的頁面中

  <v-touch
    @swipeleft = "swipeLeft"
    @swiperight = "swipeRight"
    :swipe-options="{direction: 'horizontal'}"
  >
  </v-touch>
methods:{
// 左滑 swipeLeft(){ // 頁面跳轉或其它操作 }, // 右滑 swipeRight(){ // 頁面跳轉或其它操作 },
}

注:

:swipe-options="{direction: 'horizontal'}"  可以解決引入該組件后不許上下滑動問題

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM