> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# 切换（ComfySwitchNode）

<div class="node-meta"><code>ComfySwitchNode</code><span>utilities/logic</span><span>角色：功能节点</span></div>

If/Else Switch 节点根据布尔条件在两个可能的输入之间进行选择。当 `switch` 启用（true）时，它将 `on_true` 输入传递到输出；当禁用（false）时，它传递 `on_false`。这些输入是惰性的，因此只会对所选分支进行求值，另一个输入无需连接。

## 参数

| 参数             | 类型                 | 默认 / 范围      | 说明 |
| -------------- | ------------------ | ------------ | -- |
| `switch`       | BOOLEAN · 布尔       | true / false | —  |
| `on_false`（选填） | COMFY_MATCHTYPE_V3 | —（连线输入）      | —  |
| `on_true`（选填）  | COMFY_MATCHTYPE_V3 | —（连线输入）      | —  |

## 输出

| 输出     | 类型                 | 说明                 |
| ------ | ------------------ | ------------------ |
| output | COMFY_MATCHTYPE_V3 | COMFY_MATCHTYPE_V3 |

## 怎么接

- **上游**：同类型上游
- **下游**：同类型下游
- **接线**：上游由 同类型上游 提供 `on_false`，输出 `output`（COMFY_MATCHTYPE_V3） 交给 同类型下游。

## 使用案例

从 `switch`（true / false） 开始填就能跑起来。典型接法：`同类型上游` → 本节点 → `同类型下游`。输出类型是 COMFY_MATCHTYPE_V3，只能接同类型的输入端口，颜色对不上就是接错了。

## 端口与连线示意

![ComfySwitchNode 端口与连线示意](/svg/ComfySwitchNode.svg)

## 同类节点

[与](/nodes/10/ComfyAndNode.md) · [非](/nodes/10/ComfyNotNode.md) · [或](/nodes/10/ComfyOrNode.md)
