全国免费服务热线:

18982081108
✕

成都网站维护公司,网站安全维护,网站SEO优化,网站内容运营

vue2.0如何实现移动端滑动事件vue-touch-创新互联

这篇文章主要介绍vue2.0如何实现移动端滑动事件vue-touch,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

创新互联专注于亳州网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供亳州营销型网站建设,亳州网站制作、亳州网页设计、亳州网站官网定制、重庆小程序开发服务,打造亳州网络公司原创品牌,更为您提供亳州网站排名全网营销落地服务。

Vue-touch的使用

有时候我们不止需要有返回键,也要有手势滑动切换页面的功能时,这个时候vue-touch就派上用场了

API地址:

https://github.com/vuejs/vue-touch/tree/next

安装

npm insall vue-touch@next --save
//main.js中引入:
import VueTouch from 'vue-touch'
Vue.use(VueTouch, {name: 'v-touch'})

用法如下:

//html代码
<template>
 <v-touch v-on:swipeleft="swiperleft" v-on:swiperight="swiperright" class="wrapper">
   <div class="menu-container" ref="menuContainer">  
  <!-- 这个是内容 --> 
   </div>
 </v-touch>
</template>

export default {
 name: 'Queue',
 data () {
  return {
  }
 },
 methods: {
  swiperleft: function () {
   this.$router.push({'path':'/queuehistory'});
  },
  swiperright: function () {
   this.$router.push({'path':'/home'});
  }
 }
}

下面给大家介绍下vue2.0移动端滑动事件vue-touch,具体内容如下所述:

https://github.com/vuejs/vue-touch/tree/next

cnpm install vue-touch@next

var VueTouch = require('vue-touch')
Vue.use(VueTouch, {name: 'v-touch'})

//左划   默认渲染为div  data为参数
<v-touch v-on:swipeleft="onSwipeLeft(data)">Swipe me!</v-touch>
//点击  渲染为一个a标签
<v-touch tag="a" v-on:tap="onTap">Tap me!</v-touch>
//点击  渲染为p标签
<v-touch tag="p" v-on:tap="onTap">Tap me!</v-touch>

以上是“vue2.0如何实现移动端滑动事件vue-touch”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!