ratiw / vuetable-2-tutorial

MIT License
258 stars 67 forks source link

how to change api-url from MyVuetable.vue #35

Closed rained23 closed 7 years ago

rained23 commented 7 years ago

Hi,

I am trying to learn vuetable-2, I followed the tutorial and created the basic MyVuetable.vue. In my page I have . How can I set api-url from my index.html ?

I tried <my-vuetable api-url="something"></my-vuetable> and <my-vuetable :api-url="something"></my-vuetable> both didnt work, it only work if I set the api-url from MyVuetable.vue.

Thanks.

ratiw commented 7 years ago

@rained23 You will have to define api-url as a prop in MyVuetable, then you could pass it in index.html, like so

// MyVuetable.vue
<template>
  //...
  <vuetable ref="vuetable"
      :api-url="apiUrl"
      //...
  ></vuetable>
</template>

<script>
//...
export default {
  //...
  props: ['apiUrl'],
  data () {
    //...
  }
  <my-vuetable
    api-url="...url here..."
  ></my-vuetable>
rained23 commented 7 years ago

Thanks for your help