s8e112.5 sibling communication
This commit is contained in:
parent
e421d3c06b
commit
e43128f316
@ -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: {
|
||||
|
@ -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,
|
||||
},
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user