!66 fix(carousel): 修复索引越界

Merge pull request !66 from Sight/N/A
This commit is contained in:
就眠儀式 2022-04-20 07:39:35 +00:00 committed by Gitee
commit 60cf117d09
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -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;
}
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;
}
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;
}
break;
}
}