Polymer 聚合物2.0中的内部链接
在Polymer 2.0中实现内部链接(在同一页面内链接)的正确方法是什么?我似乎无法访问隐藏在shadowdom中的组件,因此使用Polymer 聚合物2.0中的内部链接,polymer,shadow-dom,polymer-2.x,Polymer,Shadow Dom,Polymer 2.x,在Polymer 2.0中实现内部链接(在同一页面内链接)的正确方法是什么?我似乎无法访问隐藏在shadowdom中的组件,因此使用和 我尝试过的以下代码都返回null,即使在我向组件添加id时也是如此: document.querySelector('#my_section'); //null this.$.my_section; //null this.root.querySelector('#my_section'); //null this.shadowRoot.querySele
和
我尝试过的以下代码都返回null,即使在我向组件添加id时也是如此:
document.querySelector('#my_section'); //null
this.$.my_section; //null
this.root.querySelector('#my_section'); //null
this.shadowRoot.querySelector('#my_section'); //null
也许有一种方法可以通过
实现这一点
我对聚合物很陌生,所以任何建议都将不胜感激。提前感谢。请分享更详细的代码,说明您希望访问哪些元素并进行编辑。请看这份文件
https://www.polymer-project.org/2.0/docs/devguide/dom-template
在静态节点映射下
标题显示:
this.$hash是在初始化阴影DOM时创建的。在
ready callback,在访问此之前必须调用super.ready()。$
“#我的部分”查询
?你确定要使用name吗?@daKmoR我实际上也尝试过“id”,但这也不起作用。我已经更新了问题。您是从元素内部查询,还是从元素外部查询?嗨@codeMonkey,我是从元素外部查询。