https://www.cnblogs.com/zouwangblog/p/11149588.html
<!--父组件-->
<template>
<div>
<hello-world2 :good = "good"></hello-world2> //向子组件传值
</div>
</template>
<script>
import helloWorld2 from "./HelloWorld2" //引用子组件页面
export default {
name: "HelloWorld3",
components: { 'hello-world2': helloWorld2 //注册子组件 },
data() {
return { good: "我是从hello word3传递过来的" }
},
}
</script>
<!--子组件-->
<template>
<div>{{good}}</div>
</template>
<script>
export default {
props: ['good'], //通过props获取父组件传递过来的值
data: function () {
return {}
},
methods: {}
}
</script>