![](/img/trans.png)
[英]Object doesn't support this property or method 'eq' Internet Explorer only
[英]Angular Object doesn't support property or method 'scrollTo' with Internet Explorer
在我的 Angular 6 應用程序中,我有一個方法可以執行自動滾動到頁面中。 在 Chrome 中它工作正常,但在 Internet Explorer (11) 中我收到以下錯誤:
錯誤類型錯誤:對象不支持屬性或方法“scrollTo”
這是我組件中的函數:
autoScroll(step) {
setTimeout(() => {
let element = document.getElementById(step.stepId);
if (element) {
let el= document.getElementsByClassName("elements") && document.getElementsByClassName("elements")[0];
if (el) {
el.scrollTo({
top: 50,
behavior: "smooth"
});
}
}
})
}
document.querySelector('').scrollTop = 50
使用scrollTop,希望這能幫助您解決問題。
嘗試在 polyfills.ts 文件中啟用對 IE 11 的支持。
從實際意義上講,如果您在項目中使用編譯功能,則可以考慮安裝polyfill軟件包
npm i --save core-js
要么
yarn add core-js
然后在項目的入口點頂部添加
import 'core-js'
目前, core-js polyfill庫是提供跨瀏覽器支持的最簡單方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.