How to open browser from Visual Studio Code API

前端 未结 3 1756
被撕碎了的回忆
被撕碎了的回忆 2021-02-20 00:38

I am just exploring a way in order to open the default browser from Visual Studio Code API used for developing extensions.

Following is my code :

var dis         


        
3条回答
  •  后悔当初
    2021-02-20 01:27

    There is no need for node or external libraries.

    If you are using VS Code 1.31+, use the vscode.env.open function:

    import * as vscode from 'vscode';
    
    vscode.env.openExternal(vscode.Uri.parse('https://example.com'));
    

    For older VS Code versions, use the vscode.open command:

    vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://example.com'))
    

    Both of these will open the page in the user's default browser

提交回复
热议问题