How to view an HTML file in the browser with Visual Studio Code

前端 未结 23 1718
[愿得一人]
[愿得一人] 2020-11-28 17:43

How can I view my HTML code in a browser with the new Microsoft Visual Studio Code?

With Notepad++ you have the option to Run in a browser. How can I do the same thi

23条回答
  •  天命终不由人
    2020-11-28 18:04

    probably most will be able to find a solution from the above answers but seeing as how none worked for me (vscode v1.34) i thought i'd share my experience. if at least one person finds it helpful then, cool not a wasted post, amiirte?


    anyway, my solution (windows) is built a-top of @noontz's. his configuration may have been sufficient for older versions of vscode but not with 1.34 (at least, i couldn't get it working ..).

    our configs are nearly identical save a single property -- that property being, the group property. i'm not sure why but without this, my task would not even appear in the command palette.

    so. a working tasks.json for windows users running vscode 1.34:

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Chrome",
                "type": "process",
                "command": "chrome.exe",
                "windows": {
                    "command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
                },
                "args": [
                    "${file}"
                ],
                "group": "build",
                "problemMatcher": []
            }
        ]
    }
    

    note that the problemMatcher property is not required for this to work but without it an extra manual step is imposed on you. tried to read the docs on this property but i'm too thick to understand. hopefully someone will come about and school me but yeah, thanks in advance for that. all i know is -- include this property and ctrl+shift+b opens the current html file in a new chrome tab, hassle free.


    easy.

提交回复
热议问题