Chrome检查器控制台无法与版本54.0.2840.99一起使用 [英] Chrome inspector console does not work with version 54.0.2840.99
问题描述
我使用node-inspector来调试JS版本54.0.2840.99的JS。
我在一个windows cmd控制台中输入node-inspector
并在节点--debug-brk l:\dev \另一个Windows cmd控制台中的debug\test.js
。在Chrome中打开http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858
。它可以照常调试。但我在Chrome控制台输入1 + 2
,按Enter
,没有任何反应。我希望3
输出到Chrome控制台。它适用于Chrome版本48.0.2564.116。我没有使用其他Chrome版本进行测试。
I use node-inspector to debug JS with Chrome version 54.0.2840.99.
I enter "node-inspector"
in one windows cmd console and "node --debug-brk l:\dev\debug\test.js"
in another windows cmd console. Open "http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858"
in Chrome. It's able to debug as usual. But I input "1 + 2"
in Chrome console, press "Enter"
, nothing happen. I would expect "3"
is output to Chrome console. It did work with Chrome version 48.0.2564.116. I did not test with other Chrome versions.
这是新Chrome版本的缺陷吗?如何解决问题?
我拍摄的图片如下:
Is it a defect of the new Chrome versions? How to resolve the problem? I captured the pictures as below:
推荐答案
这是由Chrome弃用造成的 KeyboardEvent.keyIdentifier 。
It's caused by Chrome deprecating KeyboardEvent.keyIdentifier.
解决方法是将 keyIdentifier
添加回 KeyboardEvent
原型。
The workaround would be to add keyIdentifier
back to the KeyboardEvent
prototype.
我还注意到 KeyboardEvent.key
字符串值是不同的从 KeyboardEvent.keyIdentifier
租用,所以我在下面显示如何处理这些差异。
I also noticed that the KeyboardEvent.key
string values are different from those from KeyboardEvent.keyIdentifier
so I show below how to handle those differences if needed.
Object.defineProperty(KeyboardEvent.prototype, 'keyIdentifier', {
get: function() {
switch (this.key) {
case "ArrowDown":
return "Down";
break;
case "ArrowLeft":
return "Left";
break;
case "ArrowRight":
return "Right";
break;
case "ArrowUp":
return "Up";
break;
case "Tab":
return "U+0009";
break;
case "Escape":
return "U+001B";
break;
default:
return this.key;
}
}
});
简单地替换 isEnterKey()
是不够的以上代码处理此修复。
Simply replacing isEnterKey()
is not sufficient and the above code handles this fix.
这篇关于Chrome检查器控制台无法与版本54.0.2840.99一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!