element-plus el-scrollbar 滚轮横向滚动
<template>
<el-scrollbar ref="refScrollbar" @wheel.prevent="handleScroll">
<div class="ct-scrollbar">
</div>
</el-scrollbar>
</template>
<script>
export default {
setup() {
const refScrollbar = ref(null)
return {
refScrollbar,
handleScroll: (e) => {
const wheelDelta = e.wheelDelta || -e.deltaY * 40
const scrollbar = refScrollbar.value
// scrollbar.wrap$获取到包裹容器的element对象
scrollbar.setScrollLeft(scrollbar.wrap$.scrollLeft + wheelDelta)
}
}
}
}
</script>
<style scoped>
.ct-scrollbar {
display: flex;
}
</style>