1. 程式人生 > >Vue 子組件接收父組件的值

Vue 子組件接收父組件的值

import urn rom 組件 methods () bsp AR ret

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>

Vue 子組件接收父組件的值