mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2026-02-28 10:03:04 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div></div>
|
||||
<p><code><strong>throw</strong></code><strong><code>()</code></strong> 方法用来向生成器抛出异常,并恢复生成器的执行,返回带有 <code>done</code> 及 <code>value</code> 两个属性的对象。</p>
|
||||
<h2 id="Syntax" name="Syntax">语法</h2>
|
||||
<pre class="syntaxbox"><code><var>gen</var>.throw(exception)</code></pre>
|
||||
<pre><code class="language-javascript"><code><var>gen</var>.throw(exception)</code></code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt><code>exception</code></dt>
|
||||
@@ -23,7 +23,7 @@
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="Example:_Using_test" name="Example:_Using_test">使用 <code>throw()</code></h3>
|
||||
<p>下面的例子展示了一个简单的生成器并使用 <span style="font-family: courier,andale mono,monospace;">throw方法</span>向该生成器抛出一个异常,该异常通常可以通过 <code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/try...catch">try...catch</a></code> 块进行捕获.</p>
|
||||
<pre class="brush: js">function* gen() {
|
||||
<pre><code class="language-javascript">function* gen() {
|
||||
while(true) {
|
||||
try {
|
||||
yield 42;
|
||||
@@ -36,7 +36,7 @@
|
||||
var g = gen();
|
||||
g.next(); // { value: 42, done: false }
|
||||
g.throw(new Error("Something went wrong")); // "Error caught!"
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="Specifications" name="Specifications">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user