2
将console.log
和debugger
语句添加到我的React.Components的正确方法是什么?React.Components中的console.log和调试器语句 - 意外令牌
只是删除它们产生Unexpected token
错误:
export class ManageCoursePage extends React.Component {
debugger;
constructor(props, context) {
super(props, context);
多一点帮助,但仍然会产生Unexpected 'debugger' statement
:
export class ManageCoursePage extends React.Component {
constructor(props, context) {
super(props, context);
debugger;
甚至浏览器的console
错误了Uncaught SyntaxError: Unexpected token ;
:
class Woot {
debugger;
}
这里到底发生了什么?
我无法在第二个示例中重现错误: http://codepen.io/FullR/pen/JEPPxR – SimpleJ
'class'主体只能包含方法声明。你不能在主体内部放置任意的语句。将'debugger'语句放在构造函数中应该可以工作。如果你得到*意外的调试器语句*,那么这可能是一个linter警告,当然你可以在调试时忽略它。你在用棉绒吗? –
确认,在浏览器的控制台中测试时,在构造函数中设置'debugger'工作。 – nullsteph