diff --git a/package/component/src/component/carousel/index.vue b/package/component/src/component/carousel/index.vue index adee963b..eab238ab 100644 --- a/package/component/src/component/carousel/index.vue +++ b/package/component/src/component/carousel/index.vue @@ -89,8 +89,9 @@ const sub = function () { if (childrens.value[i].props.id === active.value) { if (i === 0) { active.value = childrens.value[slots.length - 1].props.id; + }else{ + active.value = childrens.value[i - 1].props.id; } - active.value = childrens.value[i - 1].props.id; break; } } @@ -102,8 +103,9 @@ const add = function () { if (childrens.value[i].props.id === active.value) { if (i === childrens.value.length - 1) { active.value = childrens.value[0].props.id; + }else{ + active.value = childrens.value[i + 1].props.id; } - active.value = childrens.value[i + 1].props.id; break; } } @@ -115,8 +117,9 @@ const autoplay = () => { if (childrens.value[i].props.id === active.value) { if (i === childrens.value.length - 1) { active.value = childrens.value[0].props.id; + }else{ + active.value = childrens.value[i + 1].props.id; } - active.value = childrens.value[i + 1].props.id; break; } }