我经常使用VS Code进行Html / Css / Js开发。我经常使用以下任务(来自其他SO帖子)在浏览器中打开HTML页面:
{
"version": "0.1.0",
"command": "explorer",
"windows": {
"command": "explorer.exe"
},
"args": ["${file}"]
}
有没有办法将此任务添加为所有文件夹的默认任务?
答案 0 :(得分:1)
简短的回答是“不”。
稍微长一点的答案是,“不,但他们正在考虑如何做到这一点”,如this issue所示。
解决方法是add a snippet,您可以轻松地在新项目中添加到tasks.json。转到File > Preferences > User Snippets > json
并添加以下内容:
"Explorer Task": {
"prefix": "expTask",
"body": [
'{',
'\t"version": "0.1.0",',
'\t"command": "explorer",',
'\t"windows": {',
'\t\t"command": "explorer.exe"',
'\t},',
'\t"args": ["${file}"]',
'}'
],
"description": "Explorer task that I use so often"
},
现在,当您在任何新项目中转到tasks.json时,您可以输入expTask
(或任何您的名字),然后您可以轻松地将其删除。