注:Codespaces 目前是有限公测版,可能会有变动。 在公测期间,GitHub 不对 Codespaces 的可用性做任何保证。 有关加入公测的更多信息,请参阅“关于 Codespaces”。
打开代码空间后,您可以使用 Visual Studio Code 的功能(如文本编辑、调试和 Git 命令)进行开发。 更多信息请参阅 Visual Studio Code 文档。
为获取 Codespaces 最佳使用体验,建议使用基于 Chromium 的浏览器,如 Google Chrome 或 Microsoft Edge。 更多信息请参阅“代码空间故障排除”。
Connecting to a codespace from Visual Studio Code
您可以直接从 Visual Studio Code 连接至您的代码空间。 更多信息请参阅“从 Visual Studio Code 连接至您的代码空间”。
Navigating to your codespace
- 在任何页面顶部,单击 Codespaces(代码空间)。

- 单击您要在其中开发的代码空间的名称。

Forwarding ports
Port forwarding gives you access to TCP ports running within your codespace. For example, if you're running a web application on port 3000, you can access the application from your browser to test and debug it.
When an application running inside a codespace outputs a port to the console, Codespaces detects the localhost URL pattern and automatically forwards those ports. You can click on the URL in the terminal to open it in a browser. For example, if an application outputs http://127.0.0.1:3000 or http://localhost:3000 to the console, the log would automatically convert the output to a clickable URL for port 3000.

Alternatively, you can also use any of the following ways to forward a port.
-
You can forward a port on demand by triggering the command palette (
shift command P/shift control P) and typing "Codespaces: Forward Port". You can then enter the number of the port you want to forward.
-
You can automatically configure forwarded ports in a
.devcontainer.jsonfile using theforwardPortsproperty. -
You can add or remove forwarded ports within the Remote Explorer extension. From the Remote Explorer you can copy and paste the URLs for forwarded ports, allowing you to access them through your browser.
