2016-08-26 4 views
0

Как загрузить select в vue.js, прежде чем он станет видимым. Так что сейчас я имею это:Загрузить select в vue.js

methods: { 
    getTypes() { 
     TypeService.showAll(1) 
      .then(({ data }) => ({ 
       types: data.types 
      })); 
    } 
    } 

Здесь я получаю типы, которые будут видны в избранных так:

<select v-model="ride.type" class="Radio__admin"> 
      <option disabled selected>Type?</option> 
      <option v-for="type in types" v-bind:value="type.id"> 
    </select>  

Но когда я говорю:

init() { 
    this.getTypes(); 
    } 

I получить сообщение об ошибке:

main.js:16526 Uncaught ReferenceError: getTypes is not defined 

Как следует Я делаю это?

ответ

2

Согласно documentation методов первый доступный в created крючке:

At this stage, the instance has finished processing the options which means the following have been set up: data observation, computed properties, methods, watch/event callbacks.

Смежные вопросы