我得到了错误 Uncaught TypeError: undefined is not a promise
const p = Promise((resolve, reject) => {
resolve('ok')
})
p.then(resp => console.log(resp))
Run Code Online (Sandbox Code Playgroud)
https://jsbin.com/daluquxira/edit?js,console,output
上面的代码有什么问题?
我见过这样的代码
function abc(){
return 'abc'
}
class MyComponent extends React.Component {
static abc = abc;
render() { return <h1>{this.abc}</h1>; }
}
Run Code Online (Sandbox Code Playgroud)
其中函数abc是在反应类之外定义的。我不知道作者为什么这样做,为什么不能在课堂上这样做?