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

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

@@ -6,17 +6,17 @@
<p>你也可以使用<a href="Reference/Operators/class" title="类表达式是用来定义类的一种语法。和函数表达式相同的一点是类表达式可以是命名也可以是匿名的。如果是命名类表达式这个名字只能在类体内部才能访问到。JavaScript 的类也是基于原型继承的。">类表达式</a>定义类。但是不同于类表达式,类声明不允许再次声明已经存在的类,否则将会抛出一个类型错误。</p>
</div>
<h2 id="语法">语法</h2>
<pre class="brush: js">class <em>name</em> [extends] {
<pre><code class="language-javascript">class <em>name</em> [extends] {
// class body
}
</pre>
</code></pre>
<h2 id="描述">描述</h2>
<p>和类表达式一样,类声明体在<a href="https://developer.mozilla.orgReference/Strict_mode">严格模式</a>下运行。构造函数是可选的。</p>
<p>类声明不可以提升(这与<a href="https://developer.mozilla.orgReference/Statements/function">函数声明</a>不同)。</p>
<h2 id="示例">示例</h2>
<h3 id="声明一个类">声明一个类</h3>
<p>在下面的例子中我们首先定义一个名为Polygon的类然后继承它来创建一个名为Square的类。注意构造函数中使用的 super() 只能在构造函数中使用,并且必须在使用 this 关键字前调用。</p>
<pre class="brush: js">class Polygon {
<pre><code class="language-javascript">class Polygon {
constructor(height, width) {
this.name = 'Polygon';
this.height = height;
@@ -29,17 +29,17 @@ class Square extends Polygon {
super(length, length);
  this.name = 'Square';
}
}</pre>
}</code></pre>
<div class="warning">
<h3 id="重复定义类">重复定义类</h3>
<p>重复声明一个类会引起类型错误。</p>
<pre class="brush: js">class Foo {};
<pre><code class="language-javascript">class Foo {};
class Foo {};
// Uncaught TypeError: Identifier 'Foo' has already been declared</pre>
// Uncaught TypeError: Identifier 'Foo' has already been declared</code></pre>
<p>若之前使用类表达式定义了一个类,则再次声明这个类同样会引起类型错误。</p>
<pre class="brush: js">let Foo = class {};
<pre><code class="language-javascript">let Foo = class {};
class Foo {};
// Uncaught TypeError: Identifier 'Foo' has already been declared</pre>
// Uncaught TypeError: Identifier 'Foo' has already been declared</code></pre>
</div>
<h2 id="规范">规范</h2>
<table class="standard-table">