VueJS 插槽无法与 Stencil JS 组件一起使用?

Rut*_*rde 6 javascript vue.js stenciljs vuejs3 vuejs-slots

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

<template v-slot:body>
    //content to go inside Stencil component body slot
</template>
Run Code Online (Sandbox Code Playgroud)

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

<!-- eslint-disable-next-line  vue/no-deprecated-slot-attribute -->
<div slot="body">
    //content to go inside Stencil component body slot
</div>
Run Code Online (Sandbox Code Playgroud)

这是可行的,但我必须在各处添加禁用功能。我想以正确的方式去做。有人可以告诉我该怎么做吗?

Fab*_*lho 0

Stencil 文档对此有何评论:

Stencil 中使用的插槽是 Web 组件插槽,与 Vue 2 中使用的插槽不同。不幸的是,两者的 API 非常相似,您的 linter 可能会将两者混淆。您需要更新您的.eslintrc.js 中的 lint 规则会忽略此警告:

module.exports = {
  rules: {
    'vue/no-deprecated-slot-attribute': 'off',
  },
};
Run Code Online (Sandbox Code Playgroud)

请参阅 Stencil 文档:vue/no-deprecated-slot-attribute