Carousel add event @on-click

https://github.com/iview/iview/issues/6230
This commit is contained in:
梁灏 2019-12-16 09:43:34 +08:00
parent 410a5fbca7
commit bfb6931364

View file

@ -4,10 +4,10 @@
<Icon type="ios-arrow-back"></Icon>
</button>
<div :class="[prefixCls + '-list']">
<div :class="[prefixCls + '-track', showCopyTrack ? '' : 'higher']" :style="trackStyles" ref="originTrack">
<div :class="[prefixCls + '-track', showCopyTrack ? '' : 'higher']" :style="trackStyles" ref="originTrack" @click="handleClick('currentIndex')">
<slot></slot>
</div>
<div :class="[prefixCls + '-track', showCopyTrack ? 'higher' : '']" :style="copyTrackStyles" ref="copyTrack" v-if="loop">
<div :class="[prefixCls + '-track', showCopyTrack ? 'higher' : '']" :style="copyTrackStyles" ref="copyTrack" v-if="loop" @click="handleClick('copyTrackIndex')">
</div>
</div>
<button type="button" :class="arrowClasses" class="right" @click="arrowEvent(1)">
@ -288,6 +288,9 @@
this.trackOffset = this.trackIndex * this.listWidth;
this.trackCopyOffset = this.copyTrackIndex * this.listWidth + ofs;
});
},
handleClick (type) {
this.$emit('on-click', this[type]);
}
},
watch: {