Question 14 work

master
dohodin 2 years ago
parent bb493b3951
commit 993a0815ae

@ -32,18 +32,12 @@
<div id="TEAM" style="display: none">
<div class="team">
<team-add @add-team="addTeam"></team-add>
<team @add-team="addTeam"></team>
</div>
<teamcard v-for="team in allTeam"
:id="team.id"
:name="team.name"
:description="team.description">
</teamcard>
<button @click="exportTeam">Export</button>
</div>
<div id="RESULTS" style="display: none">
<team-fight v-bind:allTeam="allTeam"></team-fight>
<team-fight ref="addTeam"></team-fight>
</div>
</div>
@ -113,10 +107,7 @@
methods:{
addTeam: function(team){
this.allTeam.push(team);
},
exportTeam: function(){
console.log("Team to JSON :")
console.log(JSON.stringify(this.allTeam));
this.$refs.addTeam.getTeam(team);
}
}
})
@ -126,10 +117,10 @@
.component('TeamFight',TeamFight)
.component('Newscard',Newscard)
.component('Team', Team);
app.mount('#app');
</script>
</body>
</html>
<!--Ctrl Maj R-->

@ -64,7 +64,6 @@ export default {
<div>
<label>ID</label><br/>
<input type="text" v-model="id"/>
{{this.id}}
</div>
<div>
<label>Name</label><br/>

@ -12,29 +12,27 @@ export default {
},
methods: {
sendResults: function () {
try{
fetch("http://www.post-result.com", {
method: "POST",
body: JSON.stringify({
homeTeam: this.homeTeam,
homeScore: this.homeScore,
awayTeam: this.awayTeam,
awayScore: this.awayScore
})
}).then(response =>{
if (!response.ok){
throw new ConnectionError(error.message);
}
console.log("Ok, data send successfully");
}).catch(error => {
this.errorMessage=error
return null;
});
}catch (error) {
}
fetch("http://www.post-result.com", {
method: "POST",
body: JSON.stringify({
homeTeam: this.homeTeam,
homeScore: this.homeScore,
awayTeam: this.awayTeam,
awayScore: this.awayScore
})
}).then(response =>{
if (!response.ok){
throw new ConnectionError(error.message);
}
console.log("Ok, data send successfully");
}).catch(error => {
this.errorMessage=error
return null;
});
},
getTeam: function (team) {
this.allTeam.push(team);
},
},
template: `
@ -45,8 +43,7 @@ export default {
<label for="home-team">Home team:</label>
<select id="home-team" v-model="homeTeam">
<option selected disabled >Select a Team</option>
<option v-for="team in allTeam"
:name="team.name">{{ name }}
<option v-for="team in allTeam">{{ team.name }}
</option>
</select>
</div>
@ -58,8 +55,7 @@ export default {
<label for="away-team">Away team:</label>
<select id="away-team" v-model="awayTeam">
<option selected disabled>Select a Team</option>
<option v-for="team in allTeam"
:name="team.name">{{ name }}
<option v-for="team in allTeam">{{ team.name }}
</option>
</select>
</div>

@ -11,13 +11,15 @@ export default {
},
methods: {
recupTeam: function (team) {
console.log('team.addTeam', team);
this.allTeam.push(team);
this.$emit('addTeam', team);
},
editParam: function (team) {
this.teamAEdit=team
console.log('lanceEdit')
},
updateTeam: function (team) {
console.log('update')
for (var i = 0; i < this.allTeam.length; i++) {
@ -27,6 +29,11 @@ export default {
this.allTeam[i].description=team.description
}
}
},
exportTeam: function(){
console.log("Team to JSON :")
console.log(JSON.stringify(this.allTeam));
}
@ -47,6 +54,7 @@ export default {
:description="team.description"
v-on:teamEditer="editParam">
</teamCard>
<button @click="exportTeam">Export</button>
</section>
`
}

Loading…
Cancel
Save