Touch Events in Vue 2.0

本秂侑毒 提交于 2019-12-21 06:57:46

问题


I'm using Vue 2.0 and should work with swipe gestures. I have checked that there is one official plugin (named vue-touch) but as they say, Vue 2.0 is not supported yet.

I know there are tons of libraries that support swipe gestures but which library would fit better currently to get working with Vue 2.0? (in terms of lightweightness and switchability if vue-touch become compitable with vue 2.0) Or are there recommended libraries for touch events in general?


回答1:


I checked and there already is a vue-touch for Vue 2.0, it is on another branch though:

This branch is only compatible with Vue 1.0. For the Vue 2.0 compatible rewrite, see the next branch

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




回答2:


You can easily use Hammer directly in Vue. Create Vue directives to wrap the Hammer touch events you're interested in. Do this once for your whole app. This is easy and shouldn't put you off.

Vue2-hammer (1600 weekly npm downloads) also wraps hammer but for the moment I'm choosing to do this directly. Vue2-touch-events (5000 weekly npm downloads) does not leverage Hammer, which seems brave.



来源:https://stackoverflow.com/questions/42693953/touch-events-in-vue-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!