vue 插槽

//父组件内 header子组件
<header>
    <template v-slot:header> //组件内使用插槽
<h1>Here is content</h1>
  </template>
</header>
//子组件 header
<template> <div class="header"> <div>top</div> <slot name="header"></slot>//对应父组件内的v-slot:header
</div> </template>

已上显示了在父组件内的代码(包含数据)样式,显示在子组件内。

原文地址:https://www.cnblogs.com/peipeiyu/p/14859104.html