步骤:
- 右击桌面浏览器快捷方式=》属性=》复制目标中引号的位置
- VSCode中点击左下角设置
- 搜索‘open in browser’将步骤1复制的粘贴到相应位置
- 右击测试一下,如果不行,继续步骤5
- 按
ctrl+shift+p
打开命令面板,输入Configure Task
然后依次操作 - 点击‘使用模板创建 tasks.json 文件’
- 点击‘’Others 运行任意外部命令的示例‘’,进入tasks.json 文件
- 原来代码如下:
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "echo", "type": "shell", "command": "echo Hello" } ] }
对这个代码进行修改,如下:
-
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "Run HTML file with Firefox", "type": "process", "command": "firefox", "args": [ "${file}" ], "windows": { //这里写你电脑的Firefox浏览器的安装位置 "command": "E:/Program Files(x86)/liulanqi/Mozilla Firefox/firefox.exe" }, "group": { "kind": "build", "isDefault": true } } ] }
保存后打开文件,直接
右键‘
Open In Default Browser’运行
就能打开浏览器了。