使用slot卡槽,就是模板方法模式
// parent.vue<template><div><div name="tom"></div><div name="joe"><!--vue中的插槽渲染children--><slot /></div></div></template>
// stage.vue
<template>
<div>
<parent>
<!-- children的具体实现 -->
<div>child</div>
</parent>
</div>
</template>
进阶
// AnimalTemplate.vue
<template>
<div>
<slot name="head"></slot>
<slot name="body"></slot>
<slot name="foot"></slot>
</div>
</template>
// stage.vue
<template>
<div>
<animal-template>
<div slot="head">pig head</div>
<div slot="body">pig body</div>
<div slot="foot">pig foot</div>
</animal-template>
<animal-template>
<div slot="head">chicken head</div>
<div slot="body">chicken body</div>
<div slot="foot">chicken foot</div>
</animal-template>
</div>
</template>
