mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-16 07:51:52 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -27,11 +27,11 @@
|
||||
<td>字符串</td>
|
||||
<td>
|
||||
<p>只有有限的一些字符可能会被转义;禁止某些控制字符; Unicode 行分隔符 (<a class="external" href="http://unicode-table.com/cn/2028/" rel="noopener">U+2028</a>)和段分隔符 (<a class="external" href="http://unicode-table.com/cn/2029/" rel="noopener">U+2029</a>)被允许 ; 字符串必须用双引号括起来。请参考下面的示例,可以看到 <a href="Reference/Global_Objects/JSON/parse" title="JSON.parse() 方法用来解析JSON字符串,构造由字符串描述的JavaScript值或对象。提供可选的reviver函数用以在返回之前对所得到的对象执行变换(操作)。"><code>JSON.parse()</code></a> 能够正常解析,但将其当作JavaScript解析时会抛出 <a href="Reference/Global_Objects/SyntaxError" title="SyntaxError 对象代表尝试解析语法上不合法的代码的错误。"><code>SyntaxError</code></a> 错误:</p>
|
||||
<pre class="brush: js">
|
||||
<pre><code class="language-javascript">
|
||||
let code = '"\u2028\u2029"';
|
||||
JSON.parse(code); // 正常
|
||||
eval(code); // 错误
|
||||
</pre>
|
||||
</code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -84,7 +84,7 @@ JSONArray = [ ]
|
||||
or [ ArrayElements ]
|
||||
ArrayElements = JSON
|
||||
or ArrayElements , JSON
|
||||
</pre>
|
||||
</code></pre>
|
||||
<p>可以有多余的空白字符出现在<code>JSONNumber</code>(数字内部不允许包含空格)或<code>JSONString</code>(字符串内部的空格被解释为相应的字符,否则就有问题了)之外的任何位置。JSON只支持这些空白字符: 制表符(<a class="external" href="http://unicode-table.com/en/0009/" rel="noopener">U+0009</a>),回车(<a class="external" href="http://unicode-table.com/en/000D/" rel="noopener">U+000D</a>),换行(<a class="external" href="http://unicode-table.com/en/0020/" rel="noopener">U+0020</a>)以及空格(<a class="external" href="http://unicode-table.com/en/0020/" rel="noopener">U+0020</a>)。</p>
|
||||
<h2 id="Methods" name="Methods">方法</h2>
|
||||
<dl>
|
||||
@@ -96,7 +96,7 @@ ArrayElements = JSON
|
||||
<h2 id="Polyfill" name="Polyfill">Polyfill</h2>
|
||||
<p><code>JSON</code>对象可能不被老版本的浏览器支持。可以将下面的代码放到JS脚本最开始的位置,这样就可以在没有原生支持 JSON 对象的浏览器(如IE6)中使用 <code>JSON</code>对象。</p>
|
||||
<p>以下算法是对原生<code>JSON</code>对象的模仿:</p>
|
||||
<pre class="brush: js">if (!window.JSON) {
|
||||
<pre><code class="language-javascript">if (!window.JSON) {
|
||||
window.JSON = {
|
||||
parse: function(sJSON) { return eval('(' + sJSON + ')'); },
|
||||
stringify: (function () {
|
||||
@@ -134,7 +134,7 @@ ArrayElements = JSON
|
||||
})()
|
||||
};
|
||||
}
|
||||
</pre>
|
||||
</code></pre>
|
||||
<p>业界更专业, 更强大的<code>JSON</code>对象 <a class="external" href="http://remysharp.com/2010/10/08/what-is-a-polyfill/" rel="noopener" title="http://remysharp.com/2010/10/08/what-is-a-polyfill/">polyfills</a> 是 <a class="external link-https" href="https://github.com/douglascrockford/JSON-js" rel="noopener" title="https://github.com/douglascrockford/JSON-js">JSON2</a> 和 <a class="external" href="http://bestiejs.github.com/json3" rel="noopener" title="http://bestiejs.github.com/json3">JSON3</a>。</p>
|
||||
<h2 id="Specifications" name="Specifications">规范</h2>
|
||||
<table class="standard-table">
|
||||
|
||||
Reference in New Issue
Block a user