Vue

by WILLIAM CORREA

HTML

<div id="app">
  <div v-for="item in rows">
    {{ item.id }} / {{ item.name }}
  </div>
  <input type="number" v-model="page">
</div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

li {
  margin: 8px 0;
}

h2 {
  font-weight: bold;
  margin-bottom: 15px;
}

del {
  color: rgba(0, 0, 0, 0.3);
}

Vue

new Vue({
  el: "#app",
  data: ({
  	database: [],
    page: 1,
    rowsPerPage: 6
  }),
  computed: {
  	rows () {
    	const start = (this.page - 1) * this.rowsPerPage
      const end = start + this.rowsPerPage
    	return this.database.slice(start, end)
    }
  },
  created () {
    const generator = (value, index) => {
      const counter = (this.page - 1) * this.rowsPerPage + index + 1
      return {
        id: counter,
        name: `Name fake ${counter}`
      }
    }
  	this.database = Array.from({ length: 50 }, generator)
  }
})