命名插槽slot
作者:
小杰的简书 | 来源:发表于
2018-11-24 10:47 被阅读0次1.<slot> 元素有一个特殊的 name 特性,可以用于定义除默认插槽以外的多余插槽:
<div class="container">
<header>
<slot name="header"></slot>
</header>
<main>
<slot></slot>
</main>
<footer>
<slot name="footer"></slot>
</footer>
</div>
2.在父组件模板的 <template> 元素上使用 slot 特性
<base-layout>
<template slot="header">
<h1>这里是一个页面标题</h1>
</template>
<p>main 内容的一个段落。</p>
<p>main 内容的另一个段落。</p>
<template slot="footer">
<p>这里是一些联系信息</p>
</template>
</base-layout>
本文标题:命名插槽slot
本文链接:https://www.haomeiwen.com/subject/jrxsxqtx.html
网友评论