You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the template, we put the `InfiniteLoading` component at the bottom of news list, and listen it's `infinite` event by a method called `infiniteHandler`.
23
+
In the template, we put the `InfiniteLoading` component at the bottom of the news list, and listen for it's `infinite` event with a method called `infiniteHandler`.
24
24
25
-
Thenwrite the core logic,`infiniteHandler` method:
25
+
Then, we write the core logic for the`infiniteHandler` method:
26
26
27
27
```js
28
28
importaxiosfrom'axios';
@@ -56,6 +56,6 @@ export default {
56
56
};
57
57
```
58
58
59
-
In the script, we use [HN Search API](https://hn.algolia.com/api) and [axios](https://github.com/mzabriskie/axios) to fetch news data. If the server API returns an array with news data, we will push them into `list`, record current page, and tell this plugin through `$state.loaded` method that we got some data. If the server API returns an empty array, we will tell this plugin through `$state.complete` method that all data has been loaded.
59
+
In the script, we use [HN Search API](https://hn.algolia.com/api) and [axios](https://github.com/mzabriskie/axios) to fetch the news data. If the server API returns an array with the news data, we will push it into `list`, record the current page, and tell this plugin through the`$state.loaded` method that we got some data. If the server API returns an empty array, we will tell this plugin through `$state.complete` method that all data has been loaded.
60
60
61
61
Now, you can get an infinite scroll version of Hacker News, just like the preview on the right.
0 commit comments