当你的才华还撑不起你的梦想时,你只能一直前进!

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 }
}

 

posted @ 2022-08-08 17:04  One'-_-'Piece  阅读(1679)  评论(0编辑  收藏  举报