Skip to content

程序化参数#

¥Programmatic-style parameters

以下是程序式节点 node 基础文件 可用的参数。

¥These are the parameters available for node base file of programmatic-style nodes.

本文档提供了简短的代码片段,以帮助你理解代码结构和概念。有关构建节点的完整步骤(包括实际代码示例),请参阅 构建程序化风格的节点

¥This document gives short code snippets to help understand the code structure and concepts. For a full walk-through of building a node, including real-world code examples, refer to Build a programmatic-style node.

程序化风格的节点也使用 execute()。方法。有关更多信息,请参阅 Programmatic-style execute method

¥Programmatic-style nodes also use the execute() method. Refer to Programmatic-style execute method for more information.

有关所有节点可用的参数,请参阅 标准参数

¥Refer to Standard parameters for parameters available to all nodes.

defaultVersion#

数量 | 可选

¥Number | Optional

使用完整版本控制方法时,请使用 defaultVersion

¥Use defaultVersion when using the full versioning approach.

n8n 支持两种节点版本控制方法。有关更多信息,请参阅 节点版本控制

¥n8n support two methods of node versioning. Refer to Node versioning for more information.

methodsloadOptions#

¥methods and loadOptions

对象 | 可选

¥Object | Optional

包含用于程序化节点的 loadOptions 方法。你可以使用此方法查询服务以获取用户特定设置(例如从 Gmail 获取用户的电子邮件标签),然后返回这些设置并在 GUI 中呈现,以便用户可以在后续查询中包含它们。

¥Contains the loadOptions method for programmatic-style nodes. You can use this method to query the service to get user-specific settings (such as getting a user's email labels from Gmail), then return them and render them in the GUI so the user can include them in subsequent queries.

例如,n8n 的 Gmail 节点 使用 loadOptions 获取所有电子邮件标签:

¥For example, n8n's Gmail node uses loadOptions to get all email labels:

 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
	methods = {
		loadOptions: {
			// Get all the labels and display them
			async getLabels(
				this: ILoadOptionsFunctions,
			): Promise<INodePropertyOptions[]> {
				const returnData: INodePropertyOptions[] = [];
				const labels = await googleApiRequestAllItems.call(
					this,
					'labels',
					'GET',
					'/gmail/v1/users/me/labels',
				);
				for (const label of labels) {
					const labelName = label.name;
					const labelId = label.id;
					returnData.push({
						name: labelName,
						value: labelId,
					});
				}
				return returnData;
			},
		},
	};

version#

数字或数组 | 可选

¥Number or Array | Optional

使用轻量级版本控制方法时,请使用 version

¥Use version when using the light versioning approach.

如果你只有一个节点版本,则可以使用版本号。如果你想支持多个版本,请将其转换为数组,其中包含每个节点版本的编号。

¥If you have one version of your node, this can be a number. If you want to support multiple versions, turn this into an array, containing numbers for each node version.

n8n 支持两种节点版本控制方法。程序化风格的节点可以使用其中任何一种。有关更多信息,请参阅 节点版本控制

¥n8n support two methods of node versioning. Programmatic-style nodes can use either. Refer to Node versioning for more information.