L
L
lemonlimelike2018-07-29 19:53:37
Laravel
lemonlimelike, 2018-07-29 19:53:37

How to implement laravel+vue infinite scroll?

Hello. How to implement infinite scrolling in my project? On the client, I make a get request:

FetchData(){
                axios.get('/api/crud')
                .then(res=>{
                    this.contents = res.data;
                })
                .catch(err=>{
                    console.log(err.res);
                });
            }


Here is the code on the server:
public function index()
    {
        $show = Content::orderBy('id','desc')->get();
        return response()->json($show);
    }


What should I do next?
How to edit the server code so that it returns only 15 records, and when scrolling, it adds the same number to these 15?
And what then to do with the client code? Tell me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-07-29
@lemonlimelike

Set yourself vue-infinite-scroll , in the request handler, replace assignment with push. In the request itself, pass the number of records already loaded, but how to apply limit and offset in laravel - see the documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question