【问题标题】:vscode extension how to display a formvscode扩展如何显示表单
【发布时间】:2016-08-10 20:22:30
【问题描述】:

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

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

【问题讨论】:

    标签: visual-studio-code vscode-extensions


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      如果这些不能满足您的需求,您可以实现一个 webview,它允许您在 Visual Studio Code 中呈现集成的 HTML 并与扩展交换消息。

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

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

      【讨论】:

        【解决方案3】:

        他们需要输入多少数据?如果不是很多,你应该可以用一系列的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.
        

        【讨论】:

        • 是的,我想你是正确的 - 目前只能使用简单的输入框进行输入,谢谢。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-02-14
        • 2021-08-03
        • 2019-07-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-06-13
        相关资源
        最近更新 更多