---
title: "updateAttributes 命令"
description: "在 Tiptap 中使用 updateAttributes 命令为节点或标记设置新的属性值。请在我们的文档中了解更多信息！"
canonical_url: "https://tiptap.zhcndoc.com/editor/api/commands/nodes-and-marks/update-attributes"
---

# updateAttributes 命令

在 Tiptap 中使用 updateAttributes 命令为节点或标记设置新的属性值。请在我们的文档中了解更多信息！

`updateAttributes` 命令将节点或标记的属性设置为新值。未传递的属性将不被修改。

另请参见: [extendMarkRange](https://tiptap.zhcndoc.com/editor/api/commands/nodes-and-marks/extend-mark-range.md)

## 参数

`typeOrName: string | NodeType | MarkType`

传递您想要更新的类型，例如 `'heading'`。

`attributes: Record<string, any>`

这需要一个包含需要更新的属性的对象。它不需要包含所有属性。

## 使用 updateAttributes 命令

```js
// 更新节点属性
editor.commands.updateAttributes('heading', { level: 1 })

// 更新标记属性
editor.commands.updateAttributes('highlight', { color: 'pink' })
```
