简体   繁体   English

将 Svelte 与 Stencil 组件一起使用

[英]Use Svelte with Stencil components

we want to build an application with svelte but are stuck at using our components that we built with stenciljs.我们想用 svelte 构建一个应用程序,但坚持使用我们用 stenciljs 构建的组件。 At first it looked like it worked like a charm but as stencil components use the term "slot" and svelte does too, i am reveiving an error when using this component on svelte起初它看起来像一个魅力,但由于模板组件使用术语“插槽”并且 svelte 也这样做,我在 svelte 上使用此组件时遇到错误

Element with a slot='...' attribute must be a child of a component or a descendant of a custom element具有 slot='...' 属性的元素必须是组件的子元素或自定义元素的后代

. . I understand this issue, the question is how to ignore it or to tell svelte to ignore certain elements.我理解这个问题,问题是如何忽略它或告诉 svelte 忽略某些元素。 Is there a function for that?有 function 吗?

The component i try to use looks like that:我尝试使用的组件如下所示:

<my-ui-image
  slot="image"
  src="/images/image.png"
  shadow-on-image="false"
  alt="image alt"
  title="Image title"
/>

check this post for named slots -> How to get the slots value in a Svelte component?检查此帖子以获取命名插槽 -> 如何获取 Svelte 组件中的插槽值? I hope it gives you direction..希望能给你指路。。

So i tried this again and the issue is gone.所以我又试了一次,问题就消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM