Vue 子组件接收父组件的值
1.父组件
<template>
<div id="rightmenu8">
<rightmenu7 ref="rightmenu7" @child="parent3" :age="age"></rightmenu7>
</div>
</template>
<script>
import rightmenu7 from "./RightMenu7.vue";
export default {
name: "rightmenu8",
data() {
return {
age:18
}
},
methods: {
},
components: {
rightmenu7: rightmenu7
}
};
</script>
2.子组件
<template>
<div id="rightmenu7" ></div>
</template>
<script>
export default {
props:['age'],
name:"rightmenu7",
data(){
return{
}
}
}
</script>
<style>
</style>
既然选择了远方,便只顾风雨兼程