Vue.dragger 导致页面click失效

fordGIP属地: 黑龙江
字数 60

touch移动后取消导致click点击无效, 需要再次点击才可以, 这里使用touch来替代页面上的click时间,touch延迟到替换click

  • 页面所有的点击用这个组件包装
<template>
    <view @touchstart="touchstart" @touchmove="touchmove">
        <slot></slot>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                clicking: false,
                move: false,
            }
        },
        
        methods: {
            
            touchmove(e){
                this.move = true
            },
            
            touchstart(e){
                this.move = false
                if(this.clicking == true && !this.touchEnd){
                    return;
                }
                
                this.touchEnd = false
                this.clicking = true;
                setTimeout(e=>{
                    this.clicking = false
                    if(!this.move){
                        this.$emit('click')
                    }
                }, 250)
            }
        }
    }
</script>

<style>
</style>


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
0人点赞
总资产13共写了1.1W字获得95个赞共36个粉丝

推荐阅读更多精彩内容