开始情况:
父组件(Parent.vue):
<template>
........
</template>
<script>
export default {
name: 'Parent'
...........
</script
子组件(Child.vue):
<template>
........
</template>
<script>
export default {
name: 'Child'
...........
</script
这3个步骤之后,我可以按顺序在父组件模板中呈现子组件(<Child>
标签):
父组件(Parent.vue):
<template>
<!--step 3:
use the Child component tag(<Child> custom element) in the parent component template
-->
<Child></Child>
</template>
<script>
//step 1: Import the Child component to the parent component
import Child from "@/path/to/Child.vue";
export default {
name: 'Parent',
//Declare the components object
components: {
//step 2: Declare/Register your child components here
Child // Child is the child component
}
}
我的考虑正确吗?