reactjs - React.Components 中的 console.log 和调试器语句 - 意外 token

标签 reactjs console.log javascript-debugger es6-class

添加console.log的正确方法是什么?和 debugger对我的 React.Components 的声明?

只需将它们放入产品中即可 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;
}

这里到底发生了什么?

最佳答案

将您的调试器语句移动到构造函数或函数中,它会正常工作。

关于reactjs - React.Components 中的 console.log 和调试器语句 - 意外 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41400148/

相关文章:

html - 如何在 ReactJS 中使用 JsPDF 在 PDF 中呈现 html 字符串内容

javascript - 如何在 react 中使用 console.log

javascript - console.log() 和 console.debug() 的区别?

ecmascript-6 - 调试器期间未定义 ES6 模块导入

reactjs - REDUX-REACT - 发送未定义

javascript - 如何记录网络/浏览器音频输出(不是麦克风音频)

firefox - 如何像在 Chrome 中一样在 Firefox 中设置 XHR 断点

javascript - console.log 中的错误?

reactjs - 在 react 中提交表单后重定向到网站

javascript - 控制台.log( 变量 ); VS console.log( [variable] );/一个提供了另一个没有提供的信息?