fix(carousel): 修复索引越界
This commit is contained in:
parent
5aeb4efd40
commit
3bc2245a85
@ -89,8 +89,9 @@ const sub = function () {
|
|||||||
if (childrens.value[i].props.id === active.value) {
|
if (childrens.value[i].props.id === active.value) {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
active.value = childrens.value[slots.length - 1].props.id;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,8 +103,9 @@ const add = function () {
|
|||||||
if (childrens.value[i].props.id === active.value) {
|
if (childrens.value[i].props.id === active.value) {
|
||||||
if (i === childrens.value.length - 1) {
|
if (i === childrens.value.length - 1) {
|
||||||
active.value = childrens.value[0].props.id;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,8 +117,9 @@ const autoplay = () => {
|
|||||||
if (childrens.value[i].props.id === active.value) {
|
if (childrens.value[i].props.id === active.value) {
|
||||||
if (i === childrens.value.length - 1) {
|
if (i === childrens.value.length - 1) {
|
||||||
active.value = childrens.value[0].props.id;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user