简体   繁体   English

VSCode扩展:如何打开带有http URL的新窗格

[英]VSCode extensions: How do I open a new pane with an http url

In VSCode, is it possible to open a new pane pointing to an http url? 在VSCode中,是否可以打开一个指向http url的新窗格? I have a server running locally (on port 8080). 我有一台本地运行的服务器(在端口8080上)。 I want to open it as a WebView. 我想将其作为WebView打开。 I couldn't find anything that provides this in the WebView API docs . WebView API文档中找不到任何可以提供此功能的东西。

The functionality I'm looking for is similar to the snippet, except with the url opening in the VSCode editor iteself. 我正在寻找的功能与代码段相似,但在VSCode编辑器iteself中打开了url。

vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('http://locahost:8080'));

You can achieve by using an iframe within webview https://code.visualstudio.com/docs/extensions/webview 您可以通过在Webview https://code.visualstudio.com/docs/extensions/webview中使用iframe来实现

 // And set its HTML content
 panel.webview.html = 
`<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Cat Coding</title>
    </head>
    <body>
        <iframe width="100%" height="100%" src='http://locahost:8080'> </iframe>
    </body>
    </html>`;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM