parent
2866d4bf0a
commit
7ea12f3c89
@ -0,0 +1 @@
|
||||
const ERROR_COLOR = 'red';
|
@ -1,11 +1,11 @@
|
||||
export default {
|
||||
template:`
|
||||
<div>
|
||||
<section>
|
||||
<ul>
|
||||
<li><a href="#">Home</a></li>
|
||||
<li><a href="#">Teams</a></li>
|
||||
<li><a href="#">Results</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
`
|
||||
};
|
@ -0,0 +1,42 @@
|
||||
export default {
|
||||
data: function() {
|
||||
return {
|
||||
id: '',
|
||||
name: '',
|
||||
errorMessage: '',
|
||||
errorColor: ERROR_COLOR
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addTeam: function() {
|
||||
this.errorMessage = '';
|
||||
if (!this.id || !this.name) {
|
||||
this.errorMessage = 'ID and Name are required !';
|
||||
return;
|
||||
}
|
||||
|
||||
const team = { id: this.id, name: this.name};
|
||||
console.log('form.addTeam', team);
|
||||
|
||||
this.$emit('addTeam', team);
|
||||
|
||||
this.id = '';
|
||||
this.name = '';
|
||||
}
|
||||
},
|
||||
template: `<section>
|
||||
<h2>News form</h2>
|
||||
<form @submit.prevent>
|
||||
<div v-bind:style="{ color: errorColor}">{{ errorMessage }}</div>
|
||||
<div>
|
||||
<label>ID</label><br/>
|
||||
<input type="text" v-model="id"/>
|
||||
</div>
|
||||
<div>
|
||||
<label>Name</label><br/>
|
||||
<input type="text" v-model="name"/>
|
||||
</div>
|
||||
<input type="submit" value="Create Team" @click="addTeam"/>
|
||||
</form>
|
||||
</section>`
|
||||
}
|
Loading…
Reference in new issue