Answer the question
In order to leave comments, you need to log in
"Line by line" (gradual) output of response.data, how to implement?
Good afternoon again.
Tell me how you can implement a gradual output of records from the database line by line, for example, there is a "load more" button, and a limiter of 10 records, that is, if we receive 30 records when querying the database, then 10 are displayed and a button appears to load more, and only by clicking on it will load the next 10, and so on.
I did it with the help of several arrays, but is it possible to do it with the help of one?
data: {
dataGet: []
},
methods: {
getData() {
axios
.get('API сервера')
.then(response => this.dataGet = response.data)
.catch(error => {
console.log(error)
})
},
mounted () {
getData()
}
Answer the question
In order to leave comments, you need to log in
You can try to display it like this:
Well, put it in data
Well, when you click on the button:
{{ dataGet.slice(0, offset) }}
<Knopka v-if="offset < dataGet.length" @click="showMore" />
showMore(){
this.offset += 10
}
get('https://lala.ru/?offset=' + this.offset)
.then(response => this.dataGet = [...this.dataGet, ...response.data])
Add a limiter to data, make a computed property on the first <limiter> records. if there are more records than in the limiter, then show the button. By pressing the button, increase the limiter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question