简体   繁体   English

未捕获的TypeError:undefined不是一个承诺

[英]Uncaught TypeError: undefined is not a promise

I got error of Uncaught TypeError: undefined is not a promise 我得到了Uncaught TypeError: undefined is not a promise错误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 https://jsbin.com/daluquxira/edit?js,console,output

what's wrong with above code? 上面的代码有什么问题?

You need to instantiate the Promise . 您需要实例化Promise

In this case: 在这种情况下:

 const p = new Promise((resolve, reject) => { resolve('ok') }) p.then(resp => console.log(resp)) 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获(承诺)TypeError:这是未定义的 - Uncaught (in promise) TypeError: this is undefined Uncaught (in promise) TypeError: result.main is undefined - Uncaught (in promise) TypeError: result.main is undefined 未捕获(承诺)TypeError:无法读取未定义的属性'uid' - Uncaught (in promise) TypeError: Cannot read property 'uid' of undefined 未捕获(承诺)类型错误:无法读取未定义的属性“fisierUrl” - Uncaught (in promise) TypeError: Cannot read property 'fisierUrl' of undefined 未捕获(承诺):TypeError:无法读取未定义的属性“ router” - Uncaught (in promise): TypeError: Cannot read property 'router' of undefined 错误:未捕获(承诺):TypeError:无法读取未定义的属性“ customerName” - Error: Uncaught (in promise): TypeError: Cannot read property 'customerName' of undefined 未捕获(承诺)类型错误:无法读取未定义的属性“过滤器” - Uncaught (in promise) TypeError: Cannot read property 'filter' of undefined 未捕获(承诺)TypeError:无法读取未定义的属性“ ui5” - Uncaught (in promise) TypeError: Cannot read property 'ui5' of undefined 需要帮助->未捕获(承诺)TypeError:无法读取未定义的属性“ length” - Need help -> Uncaught (in promise) TypeError: Cannot read property 'length' of undefined 未捕获(承诺)TypeError:无法读取未定义的属性“ content” - Uncaught (in promise) TypeError: Cannot read property 'content' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM