在vue中使用swiper,使用内置的onclick方法,但是这个onclick中this指向的是swiper,要怎么才能获取到其中的dom数据呢?
html
<swiper :options="swiperOption" ref="mySwiper" v-if="bannerList.length"> <!-- 先加载数据否则swiper循环轮播失效 -->
<swiper-slide v-for="(item,index) in bannerList" :key="index">
<div class="banner-img"
:style="{backgroundImage: 'url(' + item.img + '?x-oss-process=image/resize,w_400)',
backgroundSize:'cover',backgroundPosition:'50% 50%'}">
</div>
</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
Js
data(){
return{
swiperOption: {
speed:500,
autoplay: {
disableOnInteraction: false,
delay: 3000,
},
loop: true,
centeredSlides:true,
loopAdditionalSlides: 100,
observer:true,
pagination: {
el: '.swiper-pagination'
},
effect: 'coverflow',
coverflowEffect: {
rotate: 0,
stretch: 10,
depth: 150,
modifier: 2,
slideShadows: false
},
on:{
click: function(e){
console.log(e)
},
},
},
}
},
我想点击swiper然后跳转到对应的链接,怎么才能获取到?
可以添加ref属性来实现