看element ui跑馬燈文檔發現只有chang事件,沒有鼠標點擊小圓點事件
html
代碼改造下,加入個變量來區分是點擊觸發的仍是自動輪播觸發的ui
htmlthis
<el-carousel :interval="3000" arrow="always" trigger='click' @change='swiperchange' @mouseenter.native="isclick = true" @mouseleave.native="isclick = false"> <el-carousel-item v-for="item in 4" :key="item"> <h3>{{ item }}</h3> </el-carousel-item> </el-carousel>
jsspa
data() { return { isclick: false, }; }, methods: { swiperchange(n,o) { if(this.isclick){ console.log('我是點擊觸發的'+n) } } }