s8e112.5 sibling communication

This commit is contained in:
Tyrel Souza 2018-04-17 21:53:02 -04:00
parent e421d3c06b
commit e43128f316
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0
3 changed files with 17 additions and 4 deletions

View File

@ -10,10 +10,11 @@
:name="name"
@nameWasReset="name = $event"
:resetFn="resetName"
:userAge="age"
></app-user-detail>
</div>
<div class="col-xs-12 col-sm-6">
<app-user-edit></app-user-edit>
<app-user-edit :userAge="age" @ageWasEdited="age = $event"></app-user-edit>
</div>
</div>
</div>
@ -27,6 +28,7 @@
data(){
return {
name: "Tyrel",
age: 29
}
},
methods: {

View File

@ -2,7 +2,7 @@
<div class="component">
<h3>You may view the User Details here</h3>
<p>Many Details</p>
<p>User Name: {{ switchName() }}</p>
<p>User Name: {{ switchName() }}, {{userAge}}</p>
<button @click="resetName">Reset Name</button>
<button @click="resetFn()">Reset Name Fn</button>
</div>
@ -10,7 +10,8 @@
<script>
export default {
props: {
props:{
userAge: Number,
name: {
type: String,
},

View File

@ -1,11 +1,21 @@
<template>
<div class="component">
<h3>You may edit the User here</h3>
<h3>You may edit the User ({{userAge}}) here</h3>
<p>Edit me!</p>
<button @click="editAge">Edit Age</button>
</div>
</template>
<script>
export default {
props: ['userAge'],
methods: {
editAge(){
this.userAge = 30;
this.$emit('ageWasEdited', this.userAge)
}
}
}
</script>
<style scoped>