Guest User

Untitled

a guest
May 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. <template>
  2. <table>
  3. <thead>
  4. <tr>
  5. <th v-for="column in columns">{{ column }}</th>
  6. </tr>
  7. <tbody>
  8. <tr v-for="row in rows">
  9. <td>{{ row }}</td>
  10. </tr>
  11. </tbody>
  12. </table>
  13. </template>
  14.  
  15. <script>
  16. export default {
  17. name: 'vue-table',
  18. props: {
  19. columns: {
  20. type: Array,
  21. default: () => ([]),
  22. },
  23. rows: {
  24. type: Array,
  25. default: () => ([]),
  26. },
  27. rowsPerPage: {
  28. type: Number,
  29. default: 5
  30. },
  31. page: {
  32. type: Number,
  33. default: 1
  34. }
  35. },
  36. computed: {
  37. shownRows () {
  38. const min = this.rowsPerPage * (this.page - 1)
  39. const max = this.rowsPerPage * this.page - 1
  40. return this.rows.filter((row, index) => (index <= max && index >= min))
  41. }
  42. }
  43. }
  44. </script>
Add Comment
Please, Sign In to add comment