vue中slot的使用

目前我需要写一个组件,在组件中用到了slot

组件其实是一个容器,类似这样:

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

用的时候,我需要将slot替换的内容都加上一个样式,比如'color:red',但是这样写是不生效的: <slot style="color:red"></slot>

想问下该怎么写,才可以加上这个样式。

阅读 1.6k
1 个回答

加载替换slot的元素上不就可以了吗

推荐问题