---
title: "toggleList 命令"
description: "在 Tiptap 中使用 toggleList 命令在不同类型的列表之间切换。了解更多信息，请查看我们的文档！"
canonical_url: "https://tiptap.zhcndoc.com/editor/api/commands/lists/toggle-list"
---

# toggleList 命令

在 Tiptap 中使用 toggleList 命令在不同类型的列表之间切换。了解更多信息，请查看我们的文档！

`toggleList` 将在不同类型的列表之间切换。

## 参数

`listTypeOrName: string | NodeType`

应用于包装列表的节点类型

`itemTypeOrName: string | NodeType`

应用于列表项的节点类型

`keepMarks?: boolean`

是否应将标记保留为列表项

`attributes?: Record<string, any>`

应应用于列表的属性。**这是可选的。**

## 使用 toggleList 命令

```js
// 切换带列表项的项目符号列表
editor.commands.toggleList('bulletList', 'listItem')

// 切换带列表项的编号列表
editor.commands.toggleList('orderedList', 'listItem')
```
