vue2.0移动端滑动事件vue-touch的实例代码
2019/6/26 23:20:41
本文主要是介绍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的实例代码,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
这篇关于vue2.0移动端滑动事件vue-touch的实例代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-30React Native常用组件-点击组件
- 2024-05-30uniapp+vue3+uv-ui手机端后台OA管理模板
- 2024-05-29Python网络爬虫的时候json=就是让你少写个json.dumps()
- 2024-05-27React Native常用组件-展示组件
- 2024-05-27React Native常用组件-列表组件
- 2024-05-09vue3开发前端表单缓存自定义指令,移动端h5必备插件
- 2024-05-09React Hooks在class组件中的使用方式
- 2024-03-30[OIDC in Action] 2. 基于OIDC(OpenID Connect)的SSO(纯JS客户端)
- 2024-03-29terraform jsonencode
- 2024-03-13vuex-persist