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

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

问题描述

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.

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

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