mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2026-02-26 17:11:20 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
<div> </div>
|
||||
<div><code><strong>finally()</strong></code> 方法返回一个<a href="Reference/Global_Objects/Promise" title="Promise 对象用于表示一个异步操作的最终状态(完成或失败),以及该异步操作的结果值。"><code>Promise</code></a>,在promise执行结束时,无论结果是fulfilled或者是rejected,在执行<a href="Reference/Global_Objects/Promise/then" title="then() 方法返回一个 Promise 。它最多需要有两个参数:Promise 的成功和失败情况的回调函数。"><code>then()</code></a>和<a href="Reference/Global_Objects/Promise/catch" title="catch() 方法返回一个Promise,并且处理拒绝的情况。它的行为与调用Promise.prototype.then(undefined, onRejected) 相同。 (事实上, calling obj.catch(onRejected) 内部calls obj.then(undefined, onRejected))."><code>catch()</code></a>后,都会执行<strong><code>finally</code></strong>指定的回调函数。这为指定执行完promise后,无论结果是fulfilled还是rejected都需要执行的代码提供了一种方式,避免同样的语句需要在<a href="Reference/Global_Objects/Promise/then" title="then() 方法返回一个 Promise 。它最多需要有两个参数:Promise 的成功和失败情况的回调函数。"><code>then()</code></a>和<a href="Reference/Global_Objects/Promise/catch" title="catch() 方法返回一个Promise,并且处理拒绝的情况。它的行为与调用Promise.prototype.then(undefined, onRejected) 相同。 (事实上, calling obj.catch(onRejected) 内部calls obj.then(undefined, onRejected))."><code>catch()</code></a>中各写一次的情况。</div>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><var>p.finally(onFinally)</var>;
|
||||
<pre><code class="language-javascript"><var>p.finally(onFinally)</var>;
|
||||
|
||||
p.finally(function() {
|
||||
// 返回状态为(resolved 或 rejected)
|
||||
});参数</pre>
|
||||
});参数</code></pre>
|
||||
<dl>
|
||||
<dt><code>onFinally</code></dt>
|
||||
<dd><code>Promise</code> 状态改变后执行的回调函数。</dd>
|
||||
@@ -27,7 +27,7 @@ p.finally(function() {
|
||||
<p><strong>注意:</strong> 在<code>finally</code>回调中 <code>throw</code>(或返回被拒绝的promise)将以 <code>throw()</code> 指定的原因拒绝新的promise.</p>
|
||||
</div>
|
||||
<h2 id="示例">示例</h2>
|
||||
<pre class="brush: js">let isLoading = true;
|
||||
<pre><code class="language-javascript">let isLoading = true;
|
||||
|
||||
fetch(myRequest).then(function(response) {
|
||||
var contentType = response.headers.get("content-type");
|
||||
@@ -40,7 +40,7 @@ fetch(myRequest).then(function(response) {
|
||||
.catch(function(error) { console.log(error); })
|
||||
.finally(function() { isLoading = false; });
|
||||
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user