mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-17 00:04:34 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<article id="wikiArticle">
|
||||
<div></div>
|
||||
<h2 id="错误信息">错误信息</h2>
|
||||
<pre class="syntaxbox">ReferenceError: "x" is not defined
|
||||
</pre>
|
||||
<pre><code class="language-javascript">ReferenceError: "x" is not defined
|
||||
</code></pre>
|
||||
<h2 id="错误类型">错误类型</h2>
|
||||
<p><a href="Reference/Global_Objects/ReferenceError" title="ReferenceError(引用错误) 对象代表当一个不存在的变量被引用时发生的错误。"><code>ReferenceError</code></a>.</p>
|
||||
<h2 id="什么地方出错了">什么地方出错了?</h2>
|
||||
@@ -12,29 +12,29 @@
|
||||
</div>
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="变量没有被声明">变量没有被声明</h3>
|
||||
<pre class="brush: js example-bad">foo.substring(1); // ReferenceError: foo is not defined
|
||||
</pre>
|
||||
<pre><code class="language-js example-bad">foo.substring(1); // ReferenceError: foo is not defined
|
||||
</code></pre>
|
||||
<p>“foo” 变量没有在任何地方被声明。它需要是某种字符串,这样 <a href="Reference/Global_Objects/String/substring" title="substring() 方法返回一个字符串在开始索引到结束索引之间的一个子集, 或从开始索引直到字符串的末尾的一个子集。"><code>String.prototype.substring()</code></a> 方法才可以正常工作。</p>
|
||||
<pre class="brush: js example-good">var foo = 'bar';
|
||||
foo.substring(1); // "ar"</pre>
|
||||
<pre><code class="language-js example-good">var foo = 'bar';
|
||||
foo.substring(1); // "ar"</code></pre>
|
||||
<h3 id="错误的作用域">错误的作用域</h3>
|
||||
<p>变量必须是在它当前的执行环境中可用的。在一个函数(<a href="/en-US/docs/Web/JavaScript/Reference/Functions">function</a>)中定义的变量不能从这个函数外部的任何地方访问,因为这个变量的作用域仅在这个函数的内部。</p>
|
||||
<pre class="brush: js example-bad">function numbers () {
|
||||
<pre><code class="language-js example-bad">function numbers () {
|
||||
var num1 = 2,
|
||||
num2 = 3;
|
||||
return num1 + num2;
|
||||
}
|
||||
|
||||
console.log(num1); // ReferenceError num1 is not defined.</pre>
|
||||
console.log(num1); // ReferenceError num1 is not defined.</code></pre>
|
||||
<p>然而,一个函数可用使用在它所被定义的作用域中的所有变量。换句话说,当一个函数被定义在全局作用域的时候,它可以访问所有在全局作用域中定义的变量。</p>
|
||||
<pre class="brush: js example-good">var num1 = 2,
|
||||
<pre><code class="language-js example-good">var num1 = 2,
|
||||
num2 = 3;
|
||||
|
||||
function numbers () {
|
||||
return num1 + num2;
|
||||
}
|
||||
|
||||
console.log(num1); // 2</pre>
|
||||
console.log(num1); // 2</code></pre>
|
||||
<h2 id="相关页面">相关页面</h2>
|
||||
<ul>
|
||||
<li><a class="glossaryLink" href="/en-US/docs/Glossary/Scope" title='Scope: The current context of execution. The context in which values and expressions are "visible," or can be referenced. If a variable or other expression is not "in the current scope," then it is unavailable for use. Scopes can also be layered in a hierarchy, so that child scopes have access to parent scopes, but not vice versa.'>Scope</a></li>
|
||||
|
||||
Reference in New Issue
Block a user