mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-15 15:20:30 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
p.catch(function(reason) {
|
||||
// 拒绝
|
||||
});
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h3 id="参数" style="line-height: 24px;">参数</h3>
|
||||
<dl>
|
||||
<dt><strong>onRejected</strong></dt>
|
||||
@@ -24,7 +24,7 @@ p.catch(function(reason) {
|
||||
<p>Internally calls <code>Promise.prototype.then</code> on the object upon which is called, passing the parameters <code>undefined</code> and the <code>onRejected</code> handler received; then returns the value of that call (which is a <a href="Reference/Global_Objects/Promise" title="Promise 对象用于表示一个异步操作的最终状态(完成或失败),以及该异步操作的结果值。"><code>Promise</code></a>).</p>
|
||||
<h2 id="示例" style="line-height: 30px;">示例</h2>
|
||||
<h3 id="使用链式语句的_catch方法" style="line-height: 24px;">使用链式语句的 <code>catch</code>方法</h3>
|
||||
<pre class="brush: js"><code>var p1 = new Promise(function(resolve, reject) {
|
||||
<pre><code class="language-javascript"><code>var p1 = new Promise(function(resolve, reject) {
|
||||
resolve('Success');
|
||||
});</code>
|
||||
|
||||
@@ -49,9 +49,9 @@ p1.then(function(value) {
|
||||
console.log('after a catch the chain is restored');
|
||||
}, function () {
|
||||
console.log('Not fired due to the catch');
|
||||
});</pre>
|
||||
});</code></pre>
|
||||
<h3 id="捕获抛出的错误" style="line-height: 30px;">捕获抛出的错误</h3>
|
||||
<pre class="brush: js"><code>// 抛出一个错误,大多数时候将调用catch方法
|
||||
<pre><code class="language-javascript"><code>// 抛出一个错误,大多数时候将调用catch方法
|
||||
var p1 = new Promise(function(resolve, reject) {
|
||||
throw 'Uh-oh!';
|
||||
});
|
||||
@@ -79,7 +79,7 @@ var p3 = new Promise(function(resolve, reject) {
|
||||
|
||||
p3.catch(function(e) {
|
||||
console.log(e); // 不会执行
|
||||
});</code></pre>
|
||||
});</code></code></pre>
|
||||
<h3 id="如果已决议" style="line-height: 30px;">如果已决议</h3>
|
||||
<pre><code>//创建一个新的 Promise ,且已决议
|
||||
var p1 = Promise.resolve("calling next");
|
||||
@@ -96,7 +96,7 @@ p2.then(function (value) {
|
||||
}, function (reason) {
|
||||
console.log("next promise's onRejected");
|
||||
console.log(reason);
|
||||
});</code></pre>
|
||||
});</code></code></pre>
|
||||
<h2 id="规范" style="line-height: 30px;">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user