This commit is contained in:
mo.duan 2019-09-19 11:54:59 +08:00
parent 7e6800231c
commit e8f22ea094
2 changed files with 15 additions and 16 deletions

View file

@ -10,18 +10,11 @@
</style>
<template>
<div style="width: 400px;">
<Carousel v-model="value1" loop arrow="always" @on-change="handleChange">
<CarouselItem>
<div class="demo-carousel">1</div>
</CarouselItem>
<CarouselItem>
<div class="demo-carousel">2</div>
</CarouselItem>
<CarouselItem>
<div class="demo-carousel">3</div>
</CarouselItem>
<CarouselItem>
<div class="demo-carousel">4</div>
<Carousel v-model="value1" loop arrow="always" @on-change="handleChange" @on-click="handlerClick">
<CarouselItem v-for="it in 4" :key="it">
<div class="demo-carousel">
{{it}}
</div>
</CarouselItem>
</Carousel>
<Button @click="value1 = 2">change</Button>
@ -36,8 +29,11 @@
},
methods: {
handleChange (old, newval) {
console.log(old, newval);
console.log(old, newval,'---on-change');
},
handlerClick(index){
console.log(index,'------on-click');
}
}
},
}
</script>

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="handlerClickEvent('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" @click="handlerClickEvent('copyTrackIndex')" ref="copyTrack" v-if="loop">
</div>
</div>
<button type="button" :class="arrowClasses" class="right" @click="arrowEvent(1)">
@ -142,6 +142,9 @@
}
},
methods: {
handlerClickEvent(type){
this.$emit('on-click',this[type]);
},
// find option component
findChild (cb) {
const find = function (child) {