简体   繁体   English

删除 StencilJS 中的组件标签

[英]Remove component tag in StencilJS

I'm trying to remove the called component tag from HTML to prevent some broken CSS from external libraries and just show the inner content.我正在尝试从 HTML 中删除被调用的组件标记,以防止外部库中的一些损坏的 CSS 并只显示内部内容。

something.component.html东西.component.html

<div>
    Hello World
</div>

another.component.html另一个.component.html

<div>
   <app-something [config]="somethingConfig"></app-something>
</div>

Then outputs:然后输出:

 <div>
    <app-something>
      <div>
          Hello World
      </div>
    </app-something>
</div>

And I want:而且我要:

<div>
  <div>
     Hello World
  </div>
</div>

This is not possible due to the nature of web components which Stencil outputs.由于 Stencil 输出的 Web 组件的性质,这是不可能的。

What you could do instead: use the CSS rule display: contents on your component which prevents it from generating a box in the layout (see https://caniuse.com/css-display-contents , still somewhat experimental).你可以做什么display: contents在你的组件上使用 CSS 规则display: contents防止它在布局中生成一个框(参见https://caniuse.com/css-display-contents ,仍然有点实验性)。


There are also functional components in Stencil ( https://stenciljs.com/docs/functional-components ) which don't generate a parent element, but those are only available within JSX, so you'll always need at least one parent Stencil component (so that you can render some JSX). Stencil ( https://stenciljs.com/docs/functional-components ) 中也有不生成父元素的功能组件,但这些仅在 JSX 中可用,因此您始终需要至少一个父 Stencil组件(以便您可以渲染一些 JSX)。

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

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