[英]Javascript objects not being defined in Internet Explorer
I have one file which contains this function:我有一个包含此功能的文件:
$(function () {
window.selected = {};
const pageFilter = new PageFilter(); <-ERROR HERE
const filters = JSON.parse(pageFilter.toString());
[do other stuff]
});
And in another file I have my PageFilters
class defined as such:在另一个文件中,我的PageFilters
类定义如下:
class PageFilter {
constructor() {
if (typeof window.Filters === "undefined") {
window.Filters = {};
window.pendingNotifications = [];
const columnFilter = Util.getParameterByName("columnFilter");
const trimedFilter = columnFilter.substring(1, columnFilter.length - 1);
if (trimedFilter.length > 0) {
const parsedColumnFilter = JSON.parse(trimedFilter);
this.addRange(parsedColumnFilter);
}
}
}
...[more methods etc.]
}
And when I run my entire project in chrome or firefox, i don't get any errors, however when I run it in Internet Explorer, I get an error when I try to create a new PageFilter()
object.当我在 chrome 或 firefox 中运行我的整个项目时,我没有收到任何错误,但是当我在 Internet Explorer 中运行它时,当我尝试创建一个新的PageFilter()
对象时出现错误。
Anyone have any insight as to why I might be getting this error only in ie and no other browsers?任何人都知道为什么我可能只在 ie 而没有其他浏览器中收到此错误? Any possible fixes?任何可能的修复?
I'm also having a similar issue in another area of my code where I try to call another javascript class from a cshtml file, and it also says that it is undefined but only in ie.我在代码的另一个区域也遇到了类似的问题,我尝试从 cshtml 文件调用另一个 javascript 类,它也说它是未定义的,但仅在 ie 中。 Any insight on this would be great, thanks!任何对此的见解都会很棒,谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.