未捕获的类型错误:undefined 不是一个承诺
2017-11-24
19517
我收到错误
Uncaught TypeError: undefined is not a promise
const p = Promise((resolve, reject) => {
resolve('ok')
})
p.then(resp => console.log(resp))
https://jsbin.com/daluquxira/edit?js,console,output
上面的代码有什么问题?
1个回答
您需要实例化
Promise
。
在本例中:
const p = new Promise((resolve, reject) => {
resolve('ok')
})
p.then(resp => console.log(resp))
Hemerson Carlin
2017-11-24