vue的tap插件_vue移动端touch插件

本文介绍了在Vue移动端开发中处理触摸事件的两种插件:vue-touch和AlloyFinger。通过安装、引入及示例代码展示了如何实现单击、双击、长按等手势事件。针对vue-touch的滚动问题,提供了解决方案,即添加特定CSS样式。同时,详细列举了AlloyFinger的各种手势回调函数及其用途。
摘要由CSDN通过智能技术生成

方法一、v-touch 官网地址

包括单击、双击、长按、缩放等手势事件

安装

npm install vue-touch@next --save

引入

main.js中引入:

import VueTouch from 'vue-touch'

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

使用

html代码

js代码

export default {

name: 'Queue',

data () {

return {

}

},

methods: {

swiperleft: function () {

this.$router.push({'path':'/queuehistory'});

},

swiperright: function () {

this.$router.push({'path':'/home'});

}

}

}

发现BUG:vue-touch不能上下滑动的问题

在v-touch标签里添加class

.v-touch{touch-action:pan-y !important;

}

参考:https://www.cnblogs.com/ichenchao/p/11697856.html

方法二:AlloyFinger (腾讯的) 官网地址

包括单击、双击、长按、缩放等手势事件

安装

npm install alloyfinger

在使用vue页面中引入

import AlloyFinger from 'alloyfinger'

方法调用

var af = new AlloyFinger(element, {

touchStart: function () { },

touchMove: function () { },

touchEnd: function () { },

touchCancel: function () { },

multipointStart: function () { },

multipointEnd: function () { },

tap: function () { },

doubleTap: function () { },

longTap: function () { },

singleTap: function () { },

rotate: function (evt) {

console.log(evt.angle);

},

pinch: function (evt) {

console.log(evt.zoom);

},

pressMove: function (evt) {

console.log(evt.deltaX);

console.log(evt.deltaY);

},

swipe: function (evt) {

console.log("swipe" + evt.direction);

}

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值