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的实例代码,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
继续阅读与本文标签相同的文章
上一篇 :
C+实现神经网络之三—神经网络的训练和测试
下一篇 :
易语言不用投递消息随意移动控件的代码
-
白皮书首发:173位大数据决策者眼中的数据中台是长这样的
2026-05-19栏目: 教程
-
Jmeter的压测使用
2026-05-19栏目: 教程
-
maven常用命令
2026-05-19栏目: 教程
-
Java常用命令之jstat
2026-05-19栏目: 教程
-
阿里云第六代云服务器实例类型、特性及可选区域介绍
2026-05-19栏目: 教程
