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

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

@@ -4,7 +4,7 @@
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/intl-numberformat-prototype-format.html" width="100%"></iframe></div>
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox"><code><var>numberFormat</var>.format(<var>number</var>)</code></pre>
<pre><code class="language-javascript"><code><var>numberFormat</var>.format(<var>number</var>)</code></code></pre>
<h3 id="参数">参数</h3>
<dl>
<dt><code>number</code></dt>
@@ -15,19 +15,19 @@
<h2 id="示例">示例</h2>
<h3 id="使用_format">使用 <code>format</code></h3>
<p>使用 <code>format</code> 格式化一个单一的货币值, 以俄罗斯为例:</p>
<pre class="brush: js">var options = { style: 'currency', currency: 'RUB' };
<pre><code class="language-javascript">var options = { style: 'currency', currency: 'RUB' };
var numberFormat = new Intl.NumberFormat('ru-RU', options);
console.log(numberFormat.format(654321.987));
// → "654 321,99 руб."
</pre>
</code></pre>
<h3 id="使用_format_和_map">使用 <code>format</code> 和 <code>map</code></h3>
<p>使用 <code>format</code> 返回的函数来格式化数组中的所有数字。注意,该函数绑定到所获得的<a href="Reference/Global_Objects/NumberFormat" title="Intl.NumberFormat是对语言敏感的格式化数字类的构造器类"><code>NumberFormat</code></a>,因此它可以直接传递给<a href="Reference/Global_Objects/Array/map" title="map() 方法创建一个新数组,其结果是该数组中的每个元素都调用一个提供的函数后返回的结果。"><code>Array.prototype.map</code></a></p>
<pre class="brush: js">var a = [123456.789, 987654.321, 456789.123];
<pre><code class="language-javascript">var a = [123456.789, 987654.321, 456789.123];
var numberFormat = new Intl.NumberFormat('es-ES');
var formatted = a.map(numberFormat.format);
console.log(formatted.join('; '));
// → "123.456,789; 987.654,321; 456.789,123"
</pre>
</code></pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>