fixe about v-for in home module

master
Aurian JAULT 1 year ago
parent 16cdd797d6
commit 43b8eee1fd

@ -1,7 +1,7 @@
class NewsService{
constructor(){}
async getNews(){
getNews(){
const url = "https://newsapi.org/v2/everything?q=esport&apiKey=1639059dc5a942089bd2d29db40ee7e7";
const api = new ApiService()
let response = api.get(url);

@ -1,6 +1,6 @@
export default{
props:{
news:[]
news:Array
},
data:function(){
return {}
@ -9,8 +9,8 @@ export default{
},
template:`
<h2>Home</h2>
<div id="Teams" v-for="nouv in news">
<news-card title="nouv.title" date="nouv.publishedAt"/>
<div id="Teams">
<news-card v-for="nouv in news" :title="nouv.title" :date="nouv.publishedAt"/>
</div>
`
}
}

@ -26,13 +26,12 @@ export default{
clickHome: function() {
if(!this.homeClicked){
const api = new NewsService();
this.news = api.getNews();
console.log(this.news);
this.homeClicked=true;
this.teamClicked=false;
let infos = api.getNews();
let infos = api.getNews();
console.log(infos)
this.news = infos
this.homeClicked=true;
this.teamClicked=false;
}
else{
this.homeClicked=false;

Loading…
Cancel
Save