2016-08-26 7 views
0

vue.jsにselectをロードするにはどうすればよいですか?vue.jsでロードを選択

<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

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

私はこのような選択に表示されますタイプを受信:だから今、私はこれをしましたエラーを取得します。

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

私はこれをします? documentation方法によると

答えて

2

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.