原生es6的promise没有finally和done?

js代码


const p1 = new Promise((resove, reject) => {

  resove('hello world');

});

p1.then((result) => {

  console.log(result);

}).finally(() => {

  console.log('finally');

});

使用babel-node执行该js,报错如下:


TypeError: p1.then(...).finally is not a function

    at Object.<anonymous> (F:/ruanyf/html-css-js/test/test.js:12:4)

    at Module._compile (module.js:570:32)

    at loader (C:\public\nvm_windows\nvm_root\nvm\v6.9.1\node_modules\babel-cli\node_modules\babel-register\lib\node.js:144:5)

    at Object.require.extensions.(anonymous function) [as .js] (C:\public\nvm_windows\nvm_root\nvm\v6.9.1\node_modules\babel-cli\node_modules\babel-register\lib\node.js:154:7)

    at Module.load (module.js:487:32)

    at tryModuleLoad (module.js:446:12)

    at Function.Module._load (module.js:438:3)

    at Function.Module.runMain (module.js:604:10)


弑天下
浏览 604回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript