“SCRIPT5039:重新声明const属性”在IE9中 [英] "SCRIPT5039: Redeclaration of const property" in IE9

查看:265
本文介绍了“SCRIPT5039:重新声明const属性”在IE9中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这已经被问到了,但那里的解决方案并没有帮助我。这是什么意思?我常规的HTML页面使用脚本标记来加载我的main_script.js文件,我首先做的是:

  var internetExplorerSucks = 30; 

所使用的变量称为FPS,但我认为它可能是由一些随机默认全局,所以我将它重命名为显然还没有被采用的东西。它仍然无法工作。我在IE调试控制台中得到这个错误:

  SCRIPT5039:重新声明const属性
main_script.js,第1行字符1

我尝试通过取出var来使其成为全局的,但仍然无法使用。应该指出的是,这不是任何函数,只是文件中的第一行代码。



一些背景:所有这些代码在Chrome中都能很好地工作, Firefox,以及Windows,OS X和Linux上的Safari。 IE是唯一不适用的浏览器。这个项目涉及使用一个HTML5画布,我至少要在IE 9中显示(我使用的是版本9),但是这个代码根本不属于画布。事实上,我似乎无法在我的main_script.js文件中声明任何变量。但是,我能够创建功能而不会遇到错误。那是我必须做的吗?把所有东西都放在一个函数中(这会涉及到很多动人的东西)?

无论如何,感谢您的帮助。



PS Internet Explorer是一场噩梦。

解决方案

我在代码中遇到了同样的问题,结果IE显示错误的行是重新宣布出现。在我的情况下,这是我以后在代码中使用的历史。您应该检查整个代码以重新声明常量。您可以尝试将部分代码注释掉,看看它何时抛出该错误。


This has been asked already, but the solution there did not help me. What does this mean exactly? My regular HTML page uses a "script" tag to load my main_script.js file, where the first thing I do is:

var internetExplorerSucks = 30;

The variable used be be called FPS, but I thought it might have been taken by some random default global, so I renamed it to something that obviously isn't already taken. Still it fails to work. I get this error in the IE debug console:

SCRIPT5039: Redeclaration of const property 
main_script.js, line 1 character 1

I tried making it a global by taking out "var", still didn't work. It should be noted that this is not in any function, just literally the first line of code in the file.

Some background: All of this code works perfectly in Chrome, Firefox, and Safari on Windows, OS X and Linux. IE is the only browser this does not work on. This project involves using an HTML5 canvas, which I got to at least display in IE 9 (I am using version 9), but this code does not immediately pertain to the canvas at all. In fact, I cannot seem to declare any variables whatsoever in my main_script.js file. I am able to, however, create functions without running into an error. Is that what I have to do? Put everything in a function (that would involve a lot of moving things around)?

Anyway, thanks for the help.

P.S. Internet Explorer is a nightmare.

解决方案

I had the same problem in my code and it turn out that IE show wrong line were the redeclaration appear. In my case it was history I use later in the code. You should check whole code for redeclaration of the constants. You can try to comment out part of the code and see when it throw that error.

这篇关于“SCRIPT5039:重新声明const属性”在IE9中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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