File size: 1,317 Bytes
c9d0005 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | ---
order: 8
title: '单点调试'
mobile: false
group:
title: 高级用法
order: 2
---
# 单点调试
XFlow 支持对单个节点进行调试。通过配置 `showTestingBtn` 展示单调调试按钮,调试按钮默认显示在节点的右上角,点击按钮可以实现节点的单点调试功能。
## 基础用法
### 1. 开启调试按钮
在节点配置中设置 `showTestingBtn: true` 即可显示默认的调试按钮:
```js
const settings = [
{
title: 'LLM',
type: 'LLM',
description: '调用大语言模型回答问题或者对自然语言进行处理',
showTestingBtn: true,
icon: {
type: 'icon-model',
bgColor: '#6172F3',
},
settingSchema: {
type: 'object',
properties: {
input: {
title: '变量一',
type: 'string',
widget: 'input',
},
},
},
},
];
```
### 2. 处理调试事件
通过 `onTesting` 回调函数处理节点的调试逻辑:
```js
<XFlow
onTesting={(node, nodes) => {
// node: 当前调试的节点
// nodes: 所有节点数据
console.log("单点调试", node, nodes);
}}
/>
```
## 示例
下面的示例展示了如何使用单点调试功能:
<code src="./demo/log/runNode/index.tsx"></code> |