pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/fixed

ient/index.455dc24ca3b6b460.js" type="module">

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

String.prototype.fixed()

已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。

String 值的 fixed() 方法创建一个 <tt> 元素字符串,其中嵌入了调用的字符串(<tt>str</tt>),这会导致该字符串以等宽字体显示。

备注:所有 HTML 包装方法都已被弃用,并且仅为了兼容性而标准化。请使用 DOM API(例如 document.createElement())代替。

语法

js
fixed()

参数

无。

返回值

一个以 <tt> 开始标签开头的字符串,接着是文本 str,然后是 </tt> 结束标签。

示例

使用 fixed()

以下示例使用 fixed 方法来更改字符串的格式:

js
const worldString = "Hello, world";
console.log(worldString.fixed()); // "<tt>Hello, world</tt>"

规范

规范
ECMAScript® 2027 Language Specification
# sec-string.prototype.fixed

浏览器兼容性

参见

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy