3

我有一个 Vue 3 应用程序和一个 StencilJS 组件库。我的一个 Stencil 组件之前使用了默认插槽,它与 Vue 配合得很好。现在我在我的 Stencil 组件中引入了命名槽,但是命名槽不再在 Vue 中工作。我知道 slot 属性已被弃用,所以我尝试了这个:

<template v-slot:body>
    //content to go inside Stencil component body slot
</template>

但是,它是空白的,因为没有呈现任何内容。现在我正在使用旧方法通过添加 Eslint 禁用来添加插槽,如下所示:

<!-- eslint-disable-next-line  vue/no-deprecated-slot-attribute -->
<div slot="body">
    //content to go inside Stencil component body slot
</div>

这是有效的,但我将不得不在任何地方添加禁用。我想以正确的方式去做。有人可以告诉我该怎么做吗?

4

0 回答 0