一、props + $emit( ) 子=>父=>子
父级:
<template>
<div>
<h1>父亲</h1>
<p>name:{
{
name }}</p>
<hr>
<Child1 :name="name" @ChildOneClick="handParentClick"></Child1>
<hr>
<Child2 :name="name"></Child2>
</div>
</template>
<script>
import Child1 from './Child1'
import Child2 from './Child2'
export default {
components:{
Child1,
Child2,
},
data() {
return {
name:"小甜甜"
}
},
methods: {
handParentClick(name){
this.name = name
}
},
}
</script>
<style scoped lang='scss'>
</style>
子1:
<templat