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

View file

@ -4,10 +4,10 @@
<Icon type="ios-arrow-back"></Icon> <Icon type="ios-arrow-back"></Icon>
</button> </button>
<div :class="[prefixCls + '-list']"> <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> <slot></slot>
</div> </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>
</div> </div>
<button type="button" :class="arrowClasses" class="right" @click="arrowEvent(1)"> <button type="button" :class="arrowClasses" class="right" @click="arrowEvent(1)">
@ -142,6 +142,9 @@
} }
}, },
methods: { methods: {
handlerClickEvent(type){
this.$emit('on-click',this[type]);
},
// find option component // find option component
findChild (cb) { findChild (cb) {
const find = function (child) { const find = function (child) {