使用< slot>在本机< select>中元素 [英] Using <slot> in native <select> element
本文介绍了使用< slot>在本机< select>中元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图通过使用Shadow dom将内容放入其中来创建一个增强型" select
元素.这是文件(完整代码位于小故障:
I am trying to create an "enhanced" select
element by slotting contents using Shadow dom into it.
This is the file (the full code is in in Glitch:
import { LitElement, html } from 'lit-element'
export class Select extends LitElement {
render () {
return html`
<select id="_native">
<slot></slot>
</select>
`
}
}
customElements.define('nn-select', Select)
但是,似乎什么也没有.将 select
重命名为 select2
可解决"问题.
However, nothing seems to get slotted.
Renaming select
into select2
"solves" the problem.
是否有限制,所以我们不能< slot>
进入本机元素?
Is there a limitation so that we cannot <slot>
into native elements?
推荐答案
是的,有一个限制:< select>
元素仅接受< option>
元素小时候.因此,您不能使用< slot>
.
Yes, there a limitation: a <select>
element accepts only <option>
elements as children. As a consequence, you cannot use <slot>
.
< tr>
和< td>
...
请参见其他关于同一主题的帖子.
这篇关于使用< slot>在本机< select>中元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文