mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
37 lines
596 B
Vue
37 lines
596 B
Vue
<template>
|
|
<div class="van-swipe-item" :style="style">
|
|
<slot></slot>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'van-swipe-item',
|
|
|
|
beforeCreate() {
|
|
this.$parent.swipes.push(this);
|
|
this.$parent.childrenOffset.push(0);
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
offset: 0,
|
|
index: this.$parent.swipes.indexOf(this)
|
|
};
|
|
},
|
|
|
|
computed: {
|
|
style() {
|
|
return {
|
|
width: this.$parent.width + 'px',
|
|
transform: `translate3d(${this.offset}px, 0, 0)`
|
|
};
|
|
}
|
|
},
|
|
|
|
destroyed() {
|
|
this.$parent.swipes.splice(this.index, 1);
|
|
}
|
|
};
|
|
</script>
|