Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
364 views
in Technique[技术] by (71.8m points)

vue的动态组件, 每个组件都有不同的slot怎么处理?

每个组件都有slot, 而且有的组件有一个slot,有的有多个slot,那么我在父页面如何写?

比如组件1是

`<template>

<div>
    <slot></slot>
    <loading></loading>
</div>

</template>`

组件二是

`<template>

<div class="header">
    <slot name="header"></slot>
</div>
<div class="content">
    <slot name="content"></slot>
</div>

</template>`

那么父页面
<keep-alive><component :is="component"/></keep-alive>
怎么在调组件1的时候传组件1的slot,在调组件2的时候传组件2的两个slot呢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

slot 是可以具名的,只要这几个不要重名就好


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...