我收到了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
上述代码有什么问题?
答案 0 :(得分:18)
您需要实例化Promise
。
在这种情况下:
const p = new Promise((resolve, reject) => {
resolve('ok')
})
p.then(resp => console.log(resp))