如何使用新的Microsoft Visual Studio code在浏览器中查看我的HTML代码?
使用notepad++,您可以选择在浏览器中运行。我如何用Visual Studio Code做同样的事情?
如何使用新的Microsoft Visual Studio code在浏览器中查看我的HTML代码?
使用notepad++,您可以选择在浏览器中运行。我如何用Visual Studio Code做同样的事情?
当前回答
@InvisibleDev -让这个在mac上工作尝试使用这个:
{
"version": "0.1.0",
"command": "Chrome",
"osx": {
"command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"args": [
"${file}"
]
}
如果你已经打开了chrome浏览器,它会在一个新的选项卡中启动你的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.
如果你只是在Mac上,这个任务。json文件:
{
"version": "0.1.0",
"command": "open",
"args": ["${file}"],
}
...在Safari中打开当前文件(假设扩展名为“.html”)所需要的全部内容。
创建任务。Json,并使用⌘+shift+b调用它。
如果你想在Chrome中打开它,那么:
{
"version": "0.1.0",
"command": "open",
"args": ["-a", "Chrome.app", "${file}"],
}
这将做你想要的,如在打开一个新的标签,如果应用程序已经打开。
@InvisibleDev -让这个在mac上工作尝试使用这个:
{
"version": "0.1.0",
"command": "Chrome",
"osx": {
"command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"args": [
"${file}"
]
}
如果你已经打开了chrome浏览器,它会在一个新的选项卡中启动你的html文件。
VS Code有一个实时服务器扩展,支持一键启动状态栏。
一些特点:
一键从状态栏启动 生活重新加载 支持Chrome调试附件
Mac -在Chrome中打开-在VS Code v 1.9.0上测试
使用Command + shift + p打开命令面板。
输入配置任务运行器,第一次这样做时,VS Code会给你下拉菜单,如果它选择了“其他”。如果你以前这样做过,VS Code会直接把你发送到tasks.json。 一旦进入任务。json文件。删除显示的脚本,替换如下:
{ “版本”:“0.1.0”, “命令”:“铬”, " osx ": { "command": "/Applications/谷歌Chrome. "应用程序/内容/ MacOS /谷歌Chrome” }, “参数”(" $ {file} ") }
切换回你的html文件,按Command + Shift + b在Chrome中查看你的页面。