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開發瀏覽器默認左右滑動行為
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/215335.html
標籤:其他
