当我通过断点或通过 console.warn 打印时,class 的 属性 显示不同

Property of class being displayed differently when I print it through a breakpoint or through console.warn

这很奇怪。我有一个带有布尔值 属性 的对象。 我想看看它是怎么做的,所以我做了一个 console.warn,这给了我预期的结果。但是,如果我在 console.warn 上放置断点并通过我的开发工具控制台显示变量,我会得到 undefined。这是怎么回事?

我的代码大概是这样的:

export default class {
  constructor () {
    this.myProperty = true
  }

  doStuff () {
    return {
      doSomething: (...args) => {
        console.warn('this.myProperty', this.myProperty) // will display true
        // If I put a breakpoint on the console.warn and print it through my dev tools, it will display undefined.
      }
    }
  }

}

正如 Bergi 提到的,这看起来像是一个 Chrome 错误:https://crbug.com/760225