iview/src/components/carousel/carousel-item.vue

44 lines
1.1 KiB
Vue
Raw Normal View History

2017-01-16 02:45:11 -06:00
<template>
<div :class="prefixCls" :style="styles"><slot></slot></div>
2017-01-16 02:45:11 -06:00
</template>
<script>
const prefixCls = 'ivu-carousel-item';
export default {
2017-01-16 04:00:52 -06:00
componentName: 'carousel-item',
name: 'CarouselItem',
2017-01-16 04:00:52 -06:00
data () {
return {
prefixCls: prefixCls,
width: 0,
2017-01-17 16:39:07 -06:00
height: 'auto',
2017-01-16 04:00:52 -06:00
left: 0
};
},
computed: {
styles () {
return {
width: `${this.width}px`,
2017-01-17 16:39:07 -06:00
height: `${this.height}`,
2017-01-16 04:00:52 -06:00
left: `${this.left}px`
};
2017-01-16 04:00:52 -06:00
}
},
mounted () {
2017-01-16 18:10:31 -06:00
this.$parent.slotChange();
},
watch: {
width (val) {
if (val && this.$parent.loop) {
this.$nextTick(() => {
this.$parent.initCopyTrackDom();
});
}
}
},
2017-01-16 18:10:31 -06:00
beforeDestroy () {
this.$parent.slotChange();
}
2017-01-16 02:45:11 -06:00
};
</script>