mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-09 15:34:05 +08:00
103 lines
6.0 KiB
HTML
103 lines
6.0 KiB
HTML
<article id="wikiArticle">
|
||
<div> <div class="blockIndicator deprecated deprecatedHeader">
|
||
<p><strong><span class="icon-only-inline" title="This is an obsolete API and is no longer guaranteed to work."><i class="icon-trash"> </i></span> 已废弃</strong><br/>该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。</p>
|
||
</div></div>
|
||
<p>fixed()方法创建了一个<tt>标签元素将字符串包裹起来,从而让这个字符串里面的内容具有固定间距。</p>
|
||
<h2 id="语法">语法</h2>
|
||
<pre><code class="language-javascript">str.fixed()
|
||
</code></pre>
|
||
<h3 id="Return_value">Return value</h3>
|
||
<p>返回一个表示 <a href="/zh-CN/docs/Web/HTML/Element/tt" title="HTML 电报文本元素 (<tt>) 产生一个内联元素,使用浏览器内置的 monotype 字体展示。这个元素用于给文本排版,使其等宽展示,就像电报那样。使用 <code> 元素来展示等宽文本可能更加普遍。"><code><tt></code></a> HTML 元素的字符串。</p>
|
||
<h2 id="描述">描述</h2>
|
||
<p id="fixed()_方法将一个字符串包裹在<tt><tt>标签中,比如_<tt>str<tt>."><code style="font-size: 14px; font-style: normal; font-weight: normal; line-height: 1.5;">fixed()</code><span style="font-size: 14px; font-weight: normal; line-height: 1.5;"> 方法将一个字符串包裹在<tt></tt>标签中,比如</span><span style="font-size: 14px; font-weight: normal; line-height: 1.5;">: </span><code style="font-size: 14px; font-style: normal; font-weight: normal; line-height: 1.5;">"<tt>str</tt>"</code><span style="font-size: 14px; font-weight: normal; line-height: 1.5;">.</span></p>
|
||
<h2 id="举例">举例</h2>
|
||
<h3 id="使用fixed()">使用fixed()</h3>
|
||
<p>下面的示例代码使用这个fixed方法来改变字符串的格式:</p>
|
||
<pre><code class="language-javascript">var worldString = 'Hello, world';
|
||
console.log(worldString.fixed()); // "<tt>Hello, world</tt>"
|
||
</code></pre>
|
||
<h2 id="说明">说明</h2>
|
||
<table class="standard-table">
|
||
<tbody>
|
||
<tr>
|
||
<th scope="col">Specification</th>
|
||
<th scope="col">Status</th>
|
||
<th scope="col">Comment</th>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.fixed" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">String.prototype.fixed</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-string.prototype.fixed" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">String.prototype.fixed</small></a></td>
|
||
<td><span class="spec-Draft">Draft</span></td>
|
||
<td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<h2 id="浏览器兼容性">浏览器兼容性</h2>
|
||
<div><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
|
||
This compatibility table still uses the old format,
|
||
because we haven't yet converted the data it contains.
|
||
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
|
||
<div class="htab">
|
||
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
|
||
<ul>
|
||
<li class="selected"><a>Desktop</a></li>
|
||
<li><a>Mobile</a></li>
|
||
</ul>
|
||
</div></div>
|
||
<div id="compat-desktop">
|
||
<table class="compat-table">
|
||
<tbody>
|
||
<tr>
|
||
<th>版本</th>
|
||
<th>Chrome</th>
|
||
<th>Firefox (Gecko)</th>
|
||
<th>Internet Explorer</th>
|
||
<th>Opera</th>
|
||
<th>Safari</th>
|
||
</tr>
|
||
<tr>
|
||
<td>Basic support</td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td>1.0 (1.7 or earlier)</td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div id="compat-mobile">
|
||
<table class="compat-table">
|
||
<tbody>
|
||
<tr>
|
||
<th>版本</th>
|
||
<th>Android</th>
|
||
<th>Chrome for Android</th>
|
||
<th>Firefox Mobile (Gecko)</th>
|
||
<th>IE Mobile</th>
|
||
<th>Opera Mobile</th>
|
||
<th>Safari Mobile</th>
|
||
</tr>
|
||
<tr>
|
||
<td>Basic support</td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td>1.0 (1.0)</td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<h2 id="相关链接">相关链接</h2>
|
||
<ul>
|
||
<li><a href="Reference/Global_Objects/String/bold" title="bold() 方法会创建 HTML 元素 “b”,并将字符串加粗展示。"><code>String.prototype.bold()</code></a></li>
|
||
<li><a href="Reference/Global_Objects/String/italics" title="The italics() method creates an <i> HTML element that causes a string to be italic."><code>String.prototype.italics()</code></a></li>
|
||
<li><a href="Reference/Global_Objects/String/strike" title="strike()方法创建<strike> HTML 元素,使字符串展示为被删除的文本。"><code>String.prototype.strike()</code></a></li>
|
||
</ul>
|
||
</article> |