s8e112.5 sibling communication
This commit is contained in:
parent
e421d3c06b
commit
e43128f316
@ -10,10 +10,11 @@
|
|||||||
:name="name"
|
:name="name"
|
||||||
@nameWasReset="name = $event"
|
@nameWasReset="name = $event"
|
||||||
:resetFn="resetName"
|
:resetFn="resetName"
|
||||||
|
:userAge="age"
|
||||||
></app-user-detail>
|
></app-user-detail>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 col-sm-6">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -27,6 +28,7 @@
|
|||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
name: "Tyrel",
|
name: "Tyrel",
|
||||||
|
age: 29
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="component">
|
<div class="component">
|
||||||
<h3>You may view the User Details here</h3>
|
<h3>You may view the User Details here</h3>
|
||||||
<p>Many Details</p>
|
<p>Many Details</p>
|
||||||
<p>User Name: {{ switchName() }}</p>
|
<p>User Name: {{ switchName() }}, {{userAge}}</p>
|
||||||
<button @click="resetName">Reset Name</button>
|
<button @click="resetName">Reset Name</button>
|
||||||
<button @click="resetFn()">Reset Name Fn</button>
|
<button @click="resetFn()">Reset Name Fn</button>
|
||||||
</div>
|
</div>
|
||||||
@ -11,6 +11,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props:{
|
props:{
|
||||||
|
userAge: Number,
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="component">
|
<div class="component">
|
||||||
<h3>You may edit the User here</h3>
|
<h3>You may edit the User ({{userAge}}) here</h3>
|
||||||
<p>Edit me!</p>
|
<p>Edit me!</p>
|
||||||
|
<button @click="editAge">Edit Age</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
export default {
|
||||||
|
props: ['userAge'],
|
||||||
|
methods: {
|
||||||
|
editAge(){
|
||||||
|
this.userAge = 30;
|
||||||
|
this.$emit('ageWasEdited', this.userAge)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
Loading…
Reference in New Issue
Block a user