便捷方法#
n8n 提供了这些方法,以便更轻松地在表达式中执行常见任务。
Python支持
你可以在代码节点中使用Python。但在表达式中不可用。
| 方法 | 描述 | 是否在代码节点中可用? |
|---|---|---|
$evaluateExpression(expression: string, itemIndex?: number) |
Evaluates a string as an expression. If you don't provide itemIndex, n8n uses the data from item 0 in the Code node. |
|
$ifEmpty(value, defaultValue) |
The $ifEmpty() function takes two parameters, tests the first to check if it's empty, then returns either the parameter (if not empty) or the second parameter (if the first is empty). The first parameter is empty if it's:
|
|
$if() |
The $if() function takes three parameters: a condition, the value to return if true, and the value to return if false. |
|
$max() |
Returns the highest of the provided numbers. | |
$min() |
Returns the lowest of the provided numbers. |
| 方法 | 描述 |
|---|---|
_evaluateExpression(expression: string, itemIndex?: number) |
Evaluates a string as an expression. If you don't provide itemIndex, n8n uses the data from item 0 in the Code node. |
_ifEmpty(value, defaultValue) |
The _ifEmpty() function takes two parameters, tests the first to check if it's empty, then returns either the parameter (if not empty) or the second parameter (if the first is empty). The first parameter is empty if it's:
|