当它是程序的第一行时,JS 错误“重新声明"var?

2022-01-23 00:00:00 constants javascript

SCRPT5039:重新声明 const 属性行 1 字符 1

line1: var editObj = null;

这是文件的开头,我检查以确保该变量不在任何其他被调用的 js 文件中.是说我以后重新声明吗?(如果是这样,那行参考没有用)或者这有什么问题?

This is the beginning of the file and I checked to make sure that variable is not in any other js files being called. Is it saying that I redeclare it later? (if so that line reference is not useful) or what is wrong with this?

推荐答案

已修复.反正对我来说.我在重新声明错误之前得到了这个错误:

Fixed it. For me, anyway. I got this error before the redeclaration error:

HTML1113: Document mode restart from Quirks to IE9 Standards 

这表明 IE 发现了它认为的错误,因此以 Quirks 模式再次加载页面.加载页面两次使它认为所有内容都被声明了两次.所以解决办法就是找出IE不喜欢的东西.

This suggests that IE finds what it thinks is an error, so loads the page again in Quirks mode. Loading the page twice makes it think everything is declared twice. So the solution is to find what IE didn't like.

首先,我通过 在线 HTML 验证器 运行该页面.接下来我通过 jsLint 运行我的 javascript.毕竟,IE9 看起来很开心.作为奖励,我有更好的代码质量.我希望.

First I ran the page through the online HTML validator. Next I ran my javascript through jsLint. After all that, IE9 seemed happy. And as a bonus I have better quality code. I hope.

相关文章