如何使用新的Microsoft Visual Studio code在浏览器中查看我的HTML代码?
使用notepad++,您可以选择在浏览器中运行。我如何用Visual Studio Code做同样的事情?
如何使用新的Microsoft Visual Studio code在浏览器中查看我的HTML代码?
使用notepad++,您可以选择在浏览器中运行。我如何用Visual Studio Code做同样的事情?
当前回答
您现在可以在浏览器中安装一个扩展视图。我在chrome的windows上测试了它,它是工作的。
Vscode版本:1.10.2
其他回答
启动本地web服务器!
(假设在项目文件夹中有index.html文件)。
在同一终端窗口(Windows中的命令提示符)运行以下命令:
npm开始
打开扩展工具栏(Ctrl + Shift + X) 在浏览器中搜索open并安装 右键点击你的html文件,选择“在浏览器中打开”(Alt + B)
以下在windows 10 ->的1.53.2版本中运行
在终端菜单中选择运行活动文件 它在默认的边缘浏览器中执行html文件
Windows -打开默认浏览器-在VS Code v 1.1.0上测试
回答既打开一个特定的文件(名称是硬编码)或打开任何其他文件。
步骤:
Use ctrl + shift + p (or F1) to open the Command Palette. Type in Tasks: Configure Task or on older versions Configure Task Runner. Selecting it will open the tasks.json file. Delete the script displayed and replace it by the following: { "version": "0.1.0", "command": "explorer", "windows": { "command": "explorer.exe" }, "args": ["test.html"] } Remember to change the "args" section of the tasks.json file to the name of your file. This will always open that specific file when you hit F5. You may also set the this to open whichever file you have open at the time by using ["${file}"] as the value for "args". Note that the $ goes outside the {...}, so ["{$file}"] is incorrect. Save the file. Switch back to your html file (in this example it's "text.html"), and press ctrl + shift + b to view your page in your Web Browser.
点击左下角的管理图标。单击扩展或快捷键Ctrl+Shift+X
然后搜索扩展与这个关键句打开默认浏览器。你会发现这个扩展。这对我更好。
现在右键单击html文件,你会看到在默认浏览器中打开或快捷键Ctrl+1在浏览器中看到html文件。