更新时间:2022-10-23 20:15:18
答案是在文档中,你引用了两行之后:
open方法返回一个模式的实例,具有以下属性的对象:
- 关闭(结果) - 可以用来关闭模式的方法,通过结果
- 关闭(原因) - 可用于关闭模态的方法,传递一个原因
- 的结果 - 当一个模式被驳回时,一个模式是封闭的得到解决,拒绝承诺
最重要的一点是在这里发生了什么承诺。在接近,
承诺解决 - 本质上,成功回调火灾。
在辞退,许被拒绝,因此在运行失败
回调来代替。
块引用>What is the difference between "dismiss" a modal and "close" a modal?
close(result) - a method that can be used to close a modal, passing a result dismiss(reason) - a method that can be used to dismiss a modal, passing a reason
The answer is in the documentation, right after the two lines you quoted:
The open method returns a modal instance, an object with the following properties:
- close(result) - a method that can be used to close a modal, passing a result
- dismiss(reason) - a method that can be used to dismiss a modal, passing a reason
- result - a promise that is resolved when a modal is closed and rejected when a modal is dismissed
The important bit here being what happens to the promise. On close, the promise is resolved - essentially, the "success" callback fires. On dismiss, the promise is rejected, therefore running the "failure" callback instead.