I am setting up my VS Code environment for the first time, but I can't figure out how to set Chrome as the default browser for the workspace.
问题:
回答1:
The other StackOverflow questions regarding the browser, had to do with opening a specific file. Here are the steps to creating a tasks.json file in a brand new environment.
- From the Tasks menu, Select 'Configure Tasks'
- The entry field prompts you for 'Select a task to configure'
- Choose 'Create tasks.json file from template'
- Edit the file to include the following block:
{
"version": "0.1.0",
"command": "Chrome",
"windows": {
"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
},
"args": ["${file}"]
}
回答2:
The method of modifying tasks.json no longer works in newer versions of Visual Studio Code. The easiest way to be able to launch your code in a browser is to install the Open in Browser extension from the marketplace.
After it is installed and VS Code is reloaded, you can go to your code and press ALT + B to launch your application in your default browser or ALT + SHIFT + B to select the browser you want to use.
You can also right click and select these option from a drop down menu, but I mention this last because this currently does not work in some versions of VS Code.
回答3:
Go to file-> preferences -> user settings -> search "By Default it will open your default favorite browser" set your browser.