语法高亮,滚动条美化,设置页面调整

This commit is contained in:
fofolee
2019-04-19 02:41:09 +08:00
parent 1e8f76c000
commit 359d29ee0b
1590 changed files with 12328 additions and 11441 deletions

View File

@@ -1,7 +1,7 @@
<article id="wikiArticle">
<div></div>
<h2 id="消息">消息</h2>
<pre class="syntaxbox">TypeError: Unable to get property {x} of undefined or null reference (Edge)
<pre><code class="language-javascript">TypeError: Unable to get property {x} of undefined or null reference (Edge)
TypeError: can't access property {x} of {y} (Firefox)
TypeError: {y} is undefined, can't access property {x} of it (Firefox)
TypeError: {y} is null, can't access property {x} of it (Firefox)
@@ -11,25 +11,25 @@ TypeError: x is undefined, can't access property "prop" of it
TypeError: x is null, can't access property "prop" of it
TypeError: can't access property "prop" of undefined
TypeError: can't access property "prop" of null
</pre>
</code></pre>
<h2 id="错误类型">错误类型</h2>
<p><a href="Reference/Global_Objects/TypeError" title="TypeError类型错误 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a>.</p>
<h2 id="哪里出错了">哪里出错了?</h2>
<p>访问了 <a href="Reference/Global_Objects/undefined" title="undefined是全局对象的一个属性。也就是说它是全局作用域的一个变量。undefined的最初值就是原始数据类型undefined。"><code>undefined</code></a><a href="Reference/Global_Objects/null" title="值 null 特指对象的值未设置。它是 JavaScript 基本类型 之一。"><code>null</code></a> 值的属性.</p>
<h2 id="例子">例子</h2>
<h3 id="无效情形">无效情形</h3>
<pre class="brush: js example-bad">// 对于undefined 以及 null 值, substring 方法无法正常工作
<pre><code class="language-js example-bad">// 对于undefined 以及 null 值, substring 方法无法正常工作
var foo = undefined;
foo.substring(1); // TypeError: x is undefined, can't access property "substring" of it
var foo = null;
foo.substring(1); // TypeError: x is null, can't access property "substring" of it
</pre>
</code></pre>
<h3 id="解决问题">解决问题</h3>
<p>为了解决<code>undefined</code> 或 <code>null</code> 值的空指针问题,你可以使用 <a href="/en-US/docs/Web/JavaScript/Reference/Operators/typeof">typeof</a> 操作符, 比如.</p>
<pre class="brush: js">if (typeof foo !== 'undefined') {
<pre><code class="language-javascript">if (typeof foo !== 'undefined') {
// 现在已经确认foo已定义可以进一步操作.
}</pre>
}</code></pre>
<h2 id="参考更多">参考更多</h2>
<ul>
<li><a href="Reference/Global_Objects/undefined" title="undefined是全局对象的一个属性。也就是说它是全局作用域的一个变量。undefined的最初值就是原始数据类型undefined。"><code>undefined</code></a></li>