Vuetable-2: how to use vuetable-2 at local JSON file ?

Created on 5 May 2017  路  3Comments  路  Source: ratiw/vuetable-2

Hello.

I want to use it at local JSON file.
I try this code.

<template>
  <vuetable ref="vuetable"
      api-url="../assets/test.json"
    :fields="fields"
  ></vuetable>
</template>

<script>
import Vuetable from 'vuetable-2/src/components/Vuetable'

export default {
  components: {
    Vuetable
  },
  data () {
    return {
      fields: [
        'name', 'email', 'birthdate',
        'address.line1', 'address.line2', 'address.zipcode'
      ]
    }
  }
}
</script>

file file structure.
2017-05-05 9 37 09

Bad out this error.

2017-05-05 9 44 24

please tell me how to use it at local JSON file.

thank you.

question

Most helpful comment

@kawamataryo You will have to use Data mode by setting api-mode to false, then supply your own local data via data prop. See this codepen.

You can also combine with what @cristijora has suggested to make your code cleaner.

Please be aware, though, that sorting, paging, and page sizing are not yet work in this mode.

<vuetable
  :api-mode="false"
  :data="localData"
></vuetable>

All 3 comments

If you want to use assets in vue-cli the best idea is to place them in the static folder. Move your json into static folder and request it with /static/test.json

@kawamataryo You will have to use Data mode by setting api-mode to false, then supply your own local data via data prop. See this codepen.

You can also combine with what @cristijora has suggested to make your code cleaner.

Please be aware, though, that sorting, paging, and page sizing are not yet work in this mode.

<vuetable
  :api-mode="false"
  :data="localData"
></vuetable>

@ratiw @cristijora Thank you so much. I'll try it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

legreco picture legreco  路  5Comments

chrislandeza picture chrislandeza  路  3Comments

hjJunior picture hjJunior  路  3Comments

arthurvasconcelos picture arthurvasconcelos  路  3Comments

wa05 picture wa05  路  3Comments