有没有办法访问线路图中的特定元素?
render() {
hyper(this.shadowRoot)`
<style>${css}</style>
<container>
${this.referenceImages.map(image => wire(image)`
<cell>
<inner-cell class="${this.returnClass()}">
</inner-cell>
</cell>
`)}
</container>
`;
}
如何访问returnClass()中的节点?
有没有一种更好的方法可以通过使用导线Is和弱引用来完成我想要做的事情?
发布于 2018-07-16 15:56:16
根据您想要访问它的方式/原因,您可以存储引用并使用<HTMLElement>.querySelector()
render() {
hyper(this.shadowRoot)`
<style>${css}</style>
<container>
${this.referenceImages.map(image => {
const el = wire(image)`
<cell>
<inner-cell class="${this.returnClass()}">
</inner-cell>
</cell>
`;
el.querySelector('inner-cell');
...
return el;
})}
</container>
`;
}https://stackoverflow.com/questions/47106884
复制相似问题