Skip to content

Commit

Permalink
[zh-cn]: Update translation of String.fixed()
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLamv-t committed Aug 22, 2023
1 parent 32f2f49 commit c48c870
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,28 @@ slug: Web/JavaScript/Reference/Global_Objects/String/fixed

{{JSRef}} {{deprecated_header}}

fixed() 方法创建了一个 \<tt> 标签元素将字符串包裹起来,从而让这个字符串里面的内容具有固定间距。
{{jsxref("String")}} 值的 **`fixed()`** 方法创建一个 {{HTMLElement("tt")}} 元素字符串,并将调用字符串嵌入其中(`<tt>str</tt>`),这会导致该字符串以等宽字体显示。

> **备注:** 所有 [HTML 包装方法](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String#html_包装器方法)都已被弃用,并且仅为了兼容性而标准化。请使用[DOM API](/zh-CN/docs/Web/API/Document_Object_Model)(例如 [`document.createElement()`](/zh-CN/docs/Web/API/Document/createElement))代替。
## 语法

```plain
str.fixed()
```js-nolint
fixed()
```

### 返回值

返回一个表示 {{HTMLElement("tt")}} HTML 元素的字符串。

## 描述

`fixed()` 方法将一个字符串包裹在\<tt>\</tt>标签中,比如:`"<tt>str</tt>"`.
一个以 `<tt>` 开始标签开头的字符串,接着是文本 `str`,然后是 `</tt>` 结束标签。

## 举例
## 示例

### 使用 fixed()

下面的示例代码使用这个 fixed 方法来改变字符串的格式
以下示例使用 `fixed` 方法来更改字符串的格式

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

Expand All @@ -40,8 +38,9 @@ console.log(worldString.fixed()); // "<tt>Hello, world</tt>"

{{Compat}}

## 相关链接
## 参见

- [`core-js``String.prototype.fixed` 的 polyfill](https://github.com/zloirock/core-js#ecmascript-string-and-regexp)
- {{jsxref("String.prototype.bold()")}}
- {{jsxref("String.prototype.italics()")}}
- {{jsxref("String.prototype.strike()")}}

0 comments on commit c48c870

Please sign in to comment.