Skip to content

Commit

Permalink
fix: elevator 计算索引出现 -1,导致组件运行报错 (#1276)
Browse files Browse the repository at this point in the history
  • Loading branch information
oasis-cloud authored Aug 2, 2023
1 parent ffea1a8 commit 2bcaa1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/packages/elevator/elevator.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const Elevator: FunctionComponent<
}

if (index > state.current.listHeight.length - 2) {
cacheIndex = state.current.listHeight.length - 2
cacheIndex = Math.max(0, state.current.listHeight.length - 2)
}

setCodeIndex(cacheIndex)
Expand Down
2 changes: 1 addition & 1 deletion src/packages/elevator/elevator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const Elevator: FunctionComponent<
}

if (index > state.current.listHeight.length - 2) {
cacheIndex = state.current.listHeight.length - 2
cacheIndex = Math.max(0, state.current.listHeight.length - 2)
}

setCodeIndex(cacheIndex)
Expand Down

0 comments on commit 2bcaa1d

Please sign in to comment.