father.vue
<template> <div> <h3>这是父组件</h3> <Child :mesText="message"></Child> </div> </template> <script> import Child from "@/components/Child.vue"; export default { components: { Child, }, data() { return { message: "父组件向子组件传值成功", }; }, }; </script>
child.vue
<template> <div> <h4>这是子组件</h4> <p>{{ mesText }}</p> </div> </template> <script> export default { name: "Child", props: { mesText: String, }, }; </script>