多亏了AmmpPT,我找到了我的答案:
我曾经
this.shadowRoot.querySelector('#id')
获取元素,然后使用
scrollIntoView()
static get properties() {
return {
result: { type: Object, notify: true },
params: { type: Object, notify: true },
hash: { type: String, notify: true, observer: '_hashChanged' },
showHealth: { type: Boolean, notify: true, value: false },
selectedSuggestionId: { type: String, notify: true, observer: '_moduleSelected' }
};
}
_hashChanged(newValue, oldValue) {
var a= '#' + newValue;
var b = this.shadowRoot.querySelector(a);
if (b) {
b.scrollIntoView();
}
}