ElementUI Carousel 取消hover暂停轮播的默认行为

Carousel 在根节点上绑定了 mouseenter 和 mouseleave:

复制代码
// carousel 源码中的模板`
`on:` `{`
  `mouseenter:` `function($event)` `{`
      `_vm.handleMouseEnter($event)`              
  `},`
  `mouseleave:` `function($event)` `{`
      `_vm.handleMouseLeave($event)` 
  `}`
`}`
`

默认handleMouseEnter和handleMouseLeave事件为:鼠标移入的时候会暂停轮播,鼠标移出会恢复轮播。

复制代码
handleMouseEnter()` `{`
  `this.hover =` `true;`   `// 用于控制箭头显示`
  `this.pauseTimer();`   `// 暂停轮播`
`},`
`handleMouseLeave()` `{`
  `this.hover =` `false;`
  `this.startTimer();`   `// 恢复轮播`
`}`
`

取消轮播方式,重写这两个方法:

复制代码
` `<el-carousel ref="bannerCarousel"` `:height="bannerHeight"` `:interval="3000" arrow="hover" indicator-position="none" @change="onBannerChange">`
        `<el-carousel-item v-for="(slide, index) in slides"` `:key="slide.key">`
          `<div class="banner-slide">`
            `<img class="banner-img"` `:src="shouldLoadBanner(index) ? getBannerImgUrl(slide.img) : ''"` `:alt="slide.title"/>`
          `</div>`
        `</el-carousel-item>`
      `</el-carousel>`
`
复制代码
const carousel =` `this.$refs.bannerCarousel`
`carousel.handleMouseEnter` `=` `function` `()` `{` 
    `this.hover =` `true` 
`}`
`carousel.handleMouseLeave` `=` `function` `()` `{` 
    `this.hover =` `false` 
`}`
`
相关推荐
JarvanMo2 分钟前
AI 写代码暴增 161 倍,移动开发有没有变得更差?
前端
梦曦i7 分钟前
RouterLink v2.5.0:H5端原生能力全面回归
前端·uni-app
小林ixn20 分钟前
React + Zustand + JWT:从零实现登录鉴权与请求拦截
前端·react.js·前端框架
葡萄城技术团队25 分钟前
下拉多选类型单元格:在 SpreadJS 里接入 xm\-select
前端
粥里有勺糖1 小时前
视野修炼-技术周刊第130期 | 光影效果
前端·javascript·github
小岛前端1 小时前
AI Skills 已经封神,但新的问题却越来越严重!
前端·后端·github
拖孩1 小时前
一个人 + AI 做的小程序,上线 15 天赚了 10 块 5
前端·后端·微信小程序
用户93983829415991 小时前
安卓自动化脚本热更新怎么做?不重新打包 APK 也能更新代码
前端
全栈项目管理程序猿1 小时前
ArcGIS JS 基础教程(13):屏幕坐标与地理坐标互转
javascript
猫七先生1 小时前
在 React 里用 PMTiles 自托管底图
前端