简体   繁体   English

Vue 范围滑块使页面无法在移动设备上滚动

[英]Vue range slider making page not scrollable on mobile

In VUE I have a range slider component that I use to display different values at set point when the user drags the slider.在 VUE 中,我有一个范围滑块组件,用于在用户拖动滑块时在设定点显示不同的值。 This is all working fine, the only problem that I have is that the slider VUE slider component is making my page not scrollable on mobile.这一切正常,我遇到的唯一问题是滑块 VUE 滑块组件使我的页面无法在移动设备上滚动。 Is the browser getting confused somehow with the drag action, meaning it doesn't know it's happening on the slider but on the actual page?浏览器是否会以某种方式与拖动动作混淆,这意味着它不知道它发生在滑块上,而是发生在实际页面上? Any ideas how I can solve this?有什么想法可以解决这个问题吗? Thanks谢谢

<div class='slider margin-top-10 margin-bottom-40'>
    <range-slider
        v-model="value"
        :min="min"
        :max="max"
        :step="step"
        :range="range"
        :height="barheight"
        :dot-height="dotheight"
        :dot-width="dotwidth"
        :piecewise-label="label"
        :process-style="processstyle">
    </range-slider>
</div>

import RangeSlider from 'vue-range-component'
export default {
    components: {
        RangeSlider
    },
    props: {
        membership: {
            type: Object,
        },
        translations: {
            type: Object
        },
        isAgency: {
            type: Boolean
        },
        clientsCap: {
            type: Number
        }
    },
    data: function() {
        return {
            value: 10,
            min: 10,
            max: 50,
            step: 10,
            data: [10, 20, 30, 40, 50,],
            range: [{label: '10'}, {label: '20'}, {label: '30'}, {label: '40'}, {label: '50'}],
            label: true,
            barheight: 3,
            dotwidth: 16,
            dotheight: 16,
            processstyle: { backgroundColor: 'transparent'}
        }
    },
    created: function(){
        this.$emit('updateImages', this.value);
    },
    watch: {
        value: function(){
            this.$emit('updateImages', this.value);
        }
    },
    computed: {
        price: function() {
            var price = this.value * this.membership.additional_images;
            if(this.isAgency)
                price = price * this.clientsCap;
            if(this.membership.priceOffered < this.membership.basePrice && this.membership.priceOffered !== undefined)
                price = price - (price * 0.10);

            return price;
        }
    }
}

This bug already fixed in github repo BUT npm repo not updated.此错误已在 github 存储库中修复,但 npm 存储库更新。 https://github.com/xwpongithub/vue-range-slider/blob/master/src/js/vue-range-slider.js#L1006 https://github.com/xwpongithub/vue-range-slider/blob/master/src/js/vue-range-slider.js#L1006

So you need remove installed package from npm所以你需要从 npm 中删除已安装的包

"vue-range-component": "^1.0.3",

and add directly from github并直接从github添加

"vue-range-component": "xwpongithub/vue-range-slider",

A solution to this problem may be the following.这个问题的解决方案可能如下。 In the created function of Vue where you have this component place the following lines.在您拥有此组件的 Vue 的 created 函数中,放置以下几行。

created () {
    VueRangeSlider.methods.handleKeyup = ()=> console.log;
    VueRangeSlider.methods.handleKeydown = ()=> console.log;
},

I also ran into the problem of entering text input fields and the fact that the scroll is blocked on mobile devices.我还遇到了输入文本输入字段的问题以及滚动在移动设备上被阻止的问题。

To solve it, I downloaded the library itself and deleted all the event processing methods and keys (keydown, keyup), this helped with a text input problem.为了解决这个问题,我下载了库本身并删除了所有事件处理方法和键(keydown、keyup),这有助于解决文本输入问题。 For scrolling, you need to delete the line f = "touchstart"对于滚动,您需要删除f = "touchstart"

您需要清除该行:x="" 和 w="" 粗略的,第 73 行和第 74 行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM