我的公司使用 Bootstrap Tour,它与 PolymerV1 完美配合,但在更新到 PolymerV2 shady dom 版本后。jQuery 选择器不能很好地工作。例如:如果使用这种方式:
// 为该元素自动生成 configurationId
$('#title-Checklist-'+configurationId+'-name') // doesn't work
$('title-Checklist-382757-name') // doesn't work too
但是,如果使用:
$('[id=title-Checklist-' + configurationId + '-name]')[0]; // it works
我尝试过其他选择器,例如:
this.shadowRoot.querySelector,
document.getElementById
this.$.title-Checklist-configurationId-name
...
一切都不行!有谁知道两者有什么区别?或在 Polymer2 shady DOM 中使用 jQuery 的任何更好的解决方案?