Skip to content

Commit 2f57d0d

Browse files
committed
Fix the issue of of empty array
1 parent 83bebad commit 2f57d0d

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-virtualised",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "Vue components developed by Vue.js 3.0 for efficiently rendering large scrollable lists and hierarchical data. vue-virtualised is able to render and update 1 million nodes within a few seconds in front-end.",
55
"keywords": [
66
"vue",

src/components/Base/VirtualisedBaseScroller.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,15 @@ export default defineComponent({
149149
`initialScrollIndex value ${initialScrollIndex.value} is not Number`
150150
);
151151
invariant(
152-
initialScrollIndex.value >= 0,
152+
!isNil(initialScrollIndex.value) ||
153+
(!isNaN(Number(initialScrollIndex.value)) &&
154+
initialScrollIndex.value >= 0),
153155
`initialScrollIndex value out of range: requested index ${initialScrollIndex.value} but minimum is 0`
154156
);
155157
invariant(
156-
initialScrollIndex.value < data.value.length,
158+
isNil(initialScrollIndex.value) ||
159+
(!isNaN(Number(initialScrollIndex.value)) &&
160+
initialScrollIndex.value < data.value.length),
157161
`initialScrollIndex value out of range: requested index ${
158162
initialScrollIndex.value
159163
} is out of 0 to ${data.value.length - 1}`

src/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createApp } from "vue";
2-
// import SimpleExample from "./examples/simple-example/SimpleExample.vue";
3-
import DemoExample from "./examples/demo-example/DemoExample.vue";
2+
import SimpleExample from "./examples/simple-example/SimpleExample.vue";
3+
// import DemoExample from "./examples/demo-example/DemoExample.vue";
44

5-
// createApp(SimpleExample).mount("#app");
6-
createApp(DemoExample).mount("#app");
5+
createApp(SimpleExample).mount("#app");
6+
// createApp(DemoExample).mount("#app");

0 commit comments

Comments
 (0)