vue 左滑返回上一页
插件:vue-directive-touch步骤:1.安装依赖npm install vue-directive-touch --save;2.main.isimport touch from 'vue-directive-touch';Vue.use(touch);3.app.vue<template><div id=&q
·
插件: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
}
更多推荐
已为社区贡献4条内容
所有评论(0)