插件:vue-directive-touch
步骤:
1.安装依赖
npm install vue-directive-touch --save;
2.main.is

import touch from 'vue-directive-touch';
Vue.use(touch);

3.app.vue

<template>
  <div id="app" v-touch:left="onSwipeLeft">
      <router-view></router-view>
  </div>
</template>

<script>
  export default {
    name: 'app',
    data () {},
    methods: {
      onSwipeLeft () {
        this.$router.go(-1)
      }
    }
  }
</script>

<style lang="less">
  body {
    background-color: #ffffff;
  }
</style>

4.最重要的一点:每个页面的触摸范围设置最大,让整个屏幕都可以touch

.container{
  width:100vw
  height:100vh
}
Logo

前往低代码交流专区

更多推荐