JavaScript Promise then() 方法
描述
then()
方法提供两个回调函数:
一个在 Promise 被 fulfilled (成功) 时运行的函数,一个在 Promise 被 rejected (失败) 时运行的函数。
语法
promise.then(fulfilled(), rejected())
参数
fulfilled() | Promise fulfilled (成功) 时运行的函数 |
rejected() | Promise rejected (失败) 时运行的函数 |
返回值
类型 | 描述 |
对象 | 新的 Promise 对象 |
浏览器支持
then()
是 ECMAScript6 (ES6) 的特性。
自 2017 年 6 月起,所有现代浏览器都支持 ES6 (JavaScript 2015)
Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
2016 年 5 月 | 2017 年 4 月 | 2017 年 6 月 | 2016 年 9 月 | 2016 年 6 月 |
then()
在 Internet Explorer 中不受支持。