Vue 鼠标滚轮控制左右滑动
<el-scrollbar ref="scrollContainer" :vertical="false" class="scroll-container tags" @wheel.native.prevent="handleScroll"> <span v-for="(item, key) in tagesList" :key="key" class="tags_item" :class="active == item.id ? 'active' : ''" type="info" size="small" closable> <span @click.prevent="gotoRoute(item)" class="tags_title">{{ item.title }}</span> <i class="el-icon-close tag_close" @click="close(item)"></i> </span> </el-scrollbar>
computed: {
scrollWrapper() {
return this.$refs.scrollContainer.$refs.wrap
}
},
methods: {
handleScroll(e) { const eventDelta = e.wheelDelta || -e.deltaY * 40 const $scrollWrapper = this.scrollWrapper $scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4 }
}
不要只满足于世界的表象,要勇于探索未知的可能