mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-17 08:26:32 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div></div>
|
||||
<p><strong><code>padStart()</code></strong> 方法用另一个字符串填充当前字符串(重复,如果需要的话),以便产生的字符串达到给定的长度。填充从当前字符串的开始(左侧)应用的。</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><var>str</var>.padStart(<var>targetLength</var> [, <var>padString</var>])</pre>
|
||||
<pre><code class="language-javascript"><var>str</var>.padStart(<var>targetLength</var> [, <var>padString</var>])</code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt><code>targetLength</code></dt>
|
||||
@@ -13,15 +13,15 @@
|
||||
<h3 id="返回值">返回值</h3>
|
||||
<p>在原字符串开头填充指定的填充字符串直到目标长度所形成的新字符串。</p>
|
||||
<h2 id="示例">示例</h2>
|
||||
<pre class="brush: js line-numbers language-js"><code class="language-js">'abc'.padStart(10); // " abc"
|
||||
<pre><code class="language-javascript"><code class="language-js">'abc'.padStart(10); // " abc"
|
||||
'abc'.padStart(10, "foo"); // "foofoofabc"
|
||||
'abc'.padStart(6,"123465"); // "123abc"
|
||||
'abc'.padStart(8, "0"); // "00000abc"
|
||||
'abc'.padStart(1); // "abc"</code></pre>
|
||||
'abc'.padStart(1); // "abc"</code></code></pre>
|
||||
<p> </p>
|
||||
<h2 id="Polyfill">Polyfill</h2>
|
||||
<p>如果原生环境不支持该方法,在其他代码之前先运行下面的代码,将创建 <code>String.prototype.padStart()</code> 方法。</p>
|
||||
<pre class="brush: js line-numbers language-js"><code class="language-js">// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
|
||||
<pre><code class="language-javascript"><code class="language-js">// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
|
||||
if (!String.prototype.padStart) {
|
||||
String.prototype.padStart = function padStart(targetLength,padString) {
|
||||
@@ -39,7 +39,7 @@ if (!String.prototype.padStart) {
|
||||
}
|
||||
};
|
||||
}</code>
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user