Sha*_*han 8 javascript node.js typescript visual-studio-code vscode-extensions
我正在探索一种方法,以便从用于开发扩展的Visual Studio Code API打开默认浏览器.
以下是我的代码:
var disposable = vscode.commands.registerCommand('extension.browser', () => {
// The code you place here will be executed every time your command is executed
vscode.Uri.call("http://facebook.com");
});
Run Code Online (Sandbox Code Playgroud)
如何使用vscode类从API打开浏览器URL.
Mat*_*ner 15
不需要节点或外部库.
如果您使用的是VS Code 1.31+,请使用以下vscode.env.open功能:
import * as vscode from 'vscode';
vscode.env.openExternal(vscode.Uri.parse('https://example.com'));
Run Code Online (Sandbox Code Playgroud)
对于较旧的VS Code版本,请使用以下vscode.open命令:
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://example.com'))
Run Code Online (Sandbox Code Playgroud)
这两个都将在用户的默认浏览器中打开页面