为什么所有JavaScript控制台日志和错误都显示第1行(开发人员工具) [英] Why are all JavaScript Console Logs and Errors showing Line 1 (Developer Tools)

查看:375
本文介绍了为什么所有JavaScript控制台日志和错误都显示第1行(开发人员工具)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Javascript项目,并使用Chrome F12 Developer Tools进行调试。出于某种原因,所有console.log输出和错误消息声称它们出现在我的js文件的 第1行 中。

...即,在每行右侧的控制台中,它表示 myFile.js:1 偶数虽然第1行没有代码,但代码明显运行在另一行。



这可能是什么原因?

$ b $显然其他人不能重现这个问题(@Bergi),所以我只能想象到Chrome在某种程度上与文件有问题(损坏的?)。清除缓存并没有帮助。



解决方案适用于我,使用新文件


  1. 将文件名更改为myFile_broken.js

  2. 创建一个新文件myFile.js

  3. 将所有内容从myFile_broken.js复制到myFile.js

新的js文件现在显示正确的行号。尽管所有属性看起来都一样,并且所有文本内容都是相同的,但新文件比原来的破损文件多出约100个字节。



希望这可以帮助有同样问题的人,并且希望根源问题有一天能够被发现并解决。 (由我在Chrome版本34.0.1847.116米和34.0.1847.131米中重现的错误)


I'm working on a Javascript project and using the Chrome F12 Developer Tools for debugging. For some reason all the console.log outputs and error messages claim that they are occuring on line 1 of my js file.

...i.e., in the Console to the right of each line it says myFile.js:1 even though there is no code on line 1, and the code is obviously running on a different line.

What could be the cause of this?

解决方案

Apparently other people weren't able to reproduce the problem (@Bergi), so I can only imagine that Chrome was somehow having a problem with the file (corrupted?). Clearing cache did not help.

The work-around solution that worked for me was to use a new file.

  1. Change file name to myFile_broken.js
  2. Create a new file myFile.js
  3. Copy all content from myFile_broken.js to myFile.js

The new js file now displays the correct line numbers. Despite all properties looking the same and all text content being the same, the new file had about 100 more bytes than the original broken file.

Hopefully this helps someone who has the same issue, and hopefully the root problem is one day discovered and fixed. (Error reproduced by me in Chrome versions 34.0.1847.116 m and 34.0.1847.131 m)

这篇关于为什么所有JavaScript控制台日志和错误都显示第1行(开发人员工具)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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