vscode 扩展如何显示表单

vscode extension how to display a form

我想创建一个 VSCode 扩展,上面有一个输入表单 - 某种输入方式。到目前为止,我只看到了扩展的文档处理或输出。

如何在 vscode 扩展程序中显示输入字段的形式?

他们需要输入多少数据?如果不是很多,你应该可以用一系列的InputBoxes

来处理它

来自https://code.visualstudio.com/docs/extensionAPI/vscode-api

showInputBox(options?: InputBoxOptions): Thenable<string>

Opens an input box to ask the user for input.

The returned value will be undefined if the input box was canceled (e.g. pressing ESC). Otherwise the returned value will be the string typed by the user or an empty string if the user did not type anything but dismissed the input box with OK.

Parameter   Description
options?: InputBoxOptions   
Configures the behavior of the input box.

Returns Description
Thenable<string>    
A promise that resolves to a string the user provided or to undefined in case of dismissal.

Visual Studio 代码 API 没有任何本机方法来显示表单以收集输入。但是,您可以将输入框、快速选择等链接在一起...您可以在 vscode.window.(...).

下找到所有这些方法

如果这些不能满足您的需求,您可以实现一个 webview,它允许您在 Visual Studio 中呈现集成的 HTML 代码和带有扩展名的交易消息。

最简单的方法是在您点击提交按钮或类似按钮后将所有收集的数据从表单发送到扩展程序。

你有一个关于如何做到这一点的很好的小教程here

另一种方法是查看您可以编辑 settings.json 中的 JSON 个对象。我以为我需要一个包含 8-10 个字段的表单,但事实证明我可以创建一个具有一系列标签和输入字段(带有类型验证)的设置模板。