Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

pagination in b table in bootstrap vue

new Vue({
  el: '#app',
  data() {
    return {
      items: [],
      fields: [{
          key: 'postId',
          label: 'Post ID'
        },
        {
          key: 'id',
          label: 'ID'
        },
        {
          key: 'name',
          label: 'Name'
        },
        {
          key: 'email',
          label: 'Email'
        },
        {
          key: 'body',
          label: 'Body'
        }
      ],
      currentPage: 0,
      perPage: 10,
      totalItems: 0
    }
  },
  mounted() {
    this.fetchData().catch(error => {
      console.error(error)
    })
  },
  methods: {
    async fetchData() {
      this.items = await fetch(`https://jsonplaceholder.typicode.com/comments?_page=${this.currentPage}&_limit=${this.perPage}`)
        .then(res => {
          this.totalItems = parseInt(res.headers.get('x-total-count'), 10)

          return res.json()
        })
        .then(items => items)
    }
  },
  watch: {
    currentPage: {
      handler: function(value) {
        this.fetchData().catch(error => {
          console.error(error)
        })
      }
    }
  }
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: add new element by index js 
Javascript :: return the sum of an array 
Javascript :: what does find return javascript 
Javascript :: array filter with multiple conditions 
Javascript :: disadvantages of array 
Javascript :: Array of indexOf 
Javascript :: jquery OR operation 
Javascript :: react handling event 
Javascript :: get js 
Javascript :: multiselect checkbox 
Javascript :: how to take last element of array javascript 
Javascript :: display none after hover 
Javascript :: search in javascript 
Javascript :: understanding currying 
Javascript :: redux workflow 
Javascript :: asyncio.sleep in javascript 
Javascript :: react native update helper 
Javascript :: update column with find sequelize 
Javascript :: how to create angular project in visual studio code windows 10 
Javascript :: node js + mongoose 
Javascript :: angular get firebase firestore 
Javascript :: GTM Qgiv 
Javascript :: delete class through the dom 
Javascript :: dart get vfirst key value of map 
Javascript :: working with binary and base64 data 
Javascript :: react-resizable-rotatable-draggable 
Javascript :: @angular/fire has missing dependencies 
Javascript :: react algoliasearch 
Javascript :: Transform raw text to links 
Javascript :: how er create json data file to train our rasa model 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =