promise.PromiseResult
时间: 2023-11-03 22:35:13 浏览: 39
promise.PromiseResult is a property in the JavaScript Promise object that represents the final result of a promise once it has been settled (resolved or rejected). It can have two possible values:
- If the promise is resolved, the PromiseResult will be the value passed to the resolve() method.
- If the promise is rejected, the PromiseResult will be the reason passed to the reject() method.
The PromiseResult can be accessed using the then() method or the catch() method, depending on whether the promise was resolved or rejected.
相关问题
Promise的PromiseResult如何获取
在Promise中,PromiseResult是指Promise的状态和结果。要获取Promise的PromiseResult,可以使用Promise的then方法或者catch方法。
使用then方法可以获取Promise的成功状态下的结果,语法如下:
```
promise.then(onFulfilled, onRejected)
```
其中,onFulfilled是一个回调函数,当Promise成功时会被调用,并且会将Promise的结果作为参数传递给该函数。
使用catch方法可以获取Promise的失败状态下的结果,语法如下:
```
promise.catch(onRejected)
```
其中,onRejected是一个回调函数,当Promise失败时会被调用,并且会将Promise的错误信息作为参数传递给该函数。
通过then方法和catch方法,可以获取到Promise的PromiseResult,即成功时的结果或失败时的错误信息。
Promise的PromiseResult
Promise的PromiseResult是指承诺的结果。它可以是任意数据类型,实际上就是resolve和reject方法传入的参数。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [promise(3)——Promise对象的两个属性:”PromiseState、PromiseResult;两个回调函数参数:resolve、...](https://blog.csdn.net/qq_45895576/article/details/114479795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [Promise(承诺)](https://blog.csdn.net/H524268015wsw/article/details/126367070)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
相关推荐
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)