2016-12-25 50 views
0

我試圖用vue-vue-resource沒有成功的vue。我究竟做錯了什麼?按照代碼

我使用CDN

我開始與vuejs和我欣賞的幫助。

<div id="beerApp"> 
<ul> 
<li v-for="cervejaria in cervejarias">{{cervejaria.name}}</li> 
</ul> 
</div> 



<script src="https://unpkg.com/[email protected]/dist/vue.js"></script> 
<script src="https://cdn.jsdelivr.net/vue.resource/1.0.3/vue-resource.min.js"></script> 

<script> 

// vue js codes will be here 
new Vue({ 
    el:'#beerApp', 

data:{ 
    cervejarias: [] 
}, 

ready:function() 
{ 
    this.$http.get('https://gist.githubusercontent.com/vedovelli/3a83755e576778088c93/raw/204ced0602760829597f5caa2680e5f7cb29bade/cervejarias.json').then((response) => { 
    this.$set('cervejarias',response.json()) 
    }, (error) => { 
    consoel.log(error) 
    }); 

} 

});

回答

1

這是因爲不再有ready()生命週期勾成的Vue 2

相反,你可以用mounted()created()生命週期鉤子去。