简体   繁体   English

lit-html:如何呈现 .innerHtml 的内容

[英]lit-html: how to render contents of .innerHtml

I'm creating a custom component library and using it inc onjuction with a react component library framework called Sitecore jss.我正在创建一个自定义组件库,并将其与名为 Sitecore jss 的 React 组件库框架结合使用。 I have the following:我有以下几点:

<custom-component><Text/></custom-component>

In this instance <Text/> renders as在这种情况下<Text/>呈现为

<span>
   <span>Stuff</span>
</span>

What I'd like to have happen in that the span inside of my custom component gets rendered as html.我希望发生的事情是我的自定义组件内部的跨度被呈现为 html。 However, using .innerHtml gives me a string of the html rather than actual html.但是,使用.innerHtml会给我一个 html 字符串而不是实际的 html。 Is there a way to get lit-html to render innerHtml as html and not as a string?有没有办法让 lit-html 将 innerHtml 呈现为 html 而不是字符串?

结果我可以在我的组件中使用<slot>元素而不是.innerHtml

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

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