父组件向子组件传值遇到bug
需求:想要实现 父组件向子组件传递数据,子组件显示数据。
问题: 调试的正常,但是子组件显示不出来,浏览器错误提示如下:
[Vue warn]: Unknown custom element: <Child> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <App> at C:\vue\base\src\App.vue)
源码:
子组件代码
<template>
<!-- 子组件显示父传递过来的属性值-->
<div>
{{ message }}
</div>
</template>
<script>
export default {
data() {
},
props: ['message'],
}
</script>
父组件
<template>
<div id="app">
<h1>111</h1>
<Child message="222"></Child>
</div>
</template>
<script>
import Child from './component/Child.vue'
export default {
name: 'app',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
},
component: {
Child
}
}
</script>