当程序的第一行时,JS错误'重新声明'var? [英] JS error 'redeclaration' of var when it's first line in program?

查看:167
本文介绍了当程序的第一行时,JS错误'重新声明'var?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

第1行: 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.

这篇关于当程序的第一行时,JS错误'重新声明'var?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆