使用Visual Studio Code打开浏览器查看HTML文件

vscode出来之前一直使用sublime,后者在编写HTML文件时可以通过点击鼠标右键,找到open in browser来启动系统默认浏览器,而vscode却没有这个功能,调试和预览起来比较麻烦。不过可以通过配置tasks.json文件来解决这个问题。

Ctrl+P打开命令面板,输入tasks.json然后回车打开这个文件,可以看到默认配置,然后修改如下:

{
    // See http://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "Chrome",    //使用chrome浏览器
    "windows": {
        "command": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe" //chrome浏览器的路径
    },
    "isShellCommand": true,
    "args": ["${file}"],    //表示对当前文件进行操作
    "showOutput": "always"
}

保存后打开一个html文件,按组合键Ctrl+Shift+B就可以使用指定的浏览器打开html文件了。

 

文章来自:http://www.cnblogs.com/undefined000/p/5466626.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3