VUE阻止移动端滑动默认行为:左右及上下
<template>
<div :id="id" class="chart" :ref="id" @touchend="remove" @touchstart="start"></div>
</template>
<script>
export default {
props: {
// 取消走势图默认事件
stopPrev: {
type: Boolean,
default: false,
},
},
//...
methods: {
start(e) {
if (this.stopPrev) {
e.preventDefault()
}
},
},
}
</script>
VUE阻止移动端左右滑动默认行为
<template>
<div :id="id" :class="{ chart: true, touch_y: stopPrev }" :ref="id" @touchend="remove"></div>
</template>
<script>
export default {
props: {
// 取消走势图横向滑动默认事件
stopPrev: {
type: Boolean,
default: false,
},
},
}
</script>
<style scoped>
.chart {
width: 100%;
height: 100%;
}
.touch_y {
touch-action: none;
touch-action: pan-y;
}
</style>
阻止移动端H5开发浏览器默认左右滑动行为