我已经下载了 the latest Visual Studio Code并且正在尝试编写一些 HTML 代码。例如,<div>, <a>, <p>
标签。但是,Visual Studio Code 中没有 HTML 建议:
我读过 this article它说:
Visual Studio Code provides basic support for HTML programming out of the box.
但是,我尝试安装 HTML 扩展:
此外,我在 settings.json
中打开了 HTML5 建议文件:
{
"workbench.colorTheme": "Visual Studio Light",
"workbench.activityBar.visible": true,
"editor.multiCursorModifier": "ctrlCmd",
"window.zoomLevel": 0,
"html.suggest.html5": true,
}
然而,HTML、CSS 建议不起作用。
我可以如何根据建议进行编码?
最佳答案
我认为问题在于 Visual Studio Code 未正确检测文件类型。如果您在这些图片中注意到,vscode 已正确检测到我正在通过图标 <>
编写 html 文件。在屏幕右下角的文件名和语言指示器旁边。
语言指示器很可能会显示 plain text
在你的情况下。单击它,屏幕顶部中央应出现一个菜单。然后尝试以下操作:
- 启用
Auto Detect
.我认为这将是第一个选项。 - 选择
Configure File Association for '.html'...
2也可以通过添加来完成
"files.associations": { "*.html": "html" }
到您的设置。
或仅添加到 settings.json (File -> Preferences -> Settings)
:
{
// Configure file associations to languages (e.g. "*.extension": "html"). These have
//precedence over the default associations of the languages installed.
"files.associations": { "*.html": "html" },
}
关于html - Visual Studio Code 中没有 HTML 建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49842125/