VS Code中已废弃HTML属性自动补全功能开启方法求助
解决HTML废弃属性自动补全问题
方法一:自定义HTML数据文件
VS Code默认的HTML语言服务未包含这类废弃属性的补全提示,你可以通过自定义数据文件手动添加:
- 在项目根目录创建
html-custom-data.json文件,内容如下:
{ "version": 1.1, "tags": [ { "name": "table", "attributes": [ { "name": "cellpadding", "description": "单元格内容与边框的间距(已废弃,建议用CSS padding替代)", "valueSets": ["number"] }, { "name": "cellspacing", "description": "单元格之间的间距(已废弃,建议用CSS border-spacing替代)", "valueSets": ["number"] } ] }, { "name": "td", "attributes": [ { "name": "height", "description": "单元格高度(已废弃,建议用CSS height替代)", "valueSets": ["length"] }, { "name": "width", "description": "单元格宽度(已废弃,建议用CSS width替代)", "valueSets": ["length"] } ] } ] }
- 在VS Code的
settings.json中添加配置,指向这个自定义文件:
"html.customData": ["./html-custom-data.json"]
重启VS Code后,输入<table>或<td>时就能看到这些废弃属性的补全提示。
方法二:检查基础配置是否正确
确保你的HTML相关配置没有禁用补全功能,在settings.json中确认:
"[html]": { "editor.suggest.enabled": true, "editor.suggest.showDeprecated": true, "editor.showDeprecated": true }
若之前editor.suggest.enabled被设为false,即使开启废弃属性显示也不会触发补全。
内容的提问来源于stack exchange,提问作者Misha Konoval
相关产品推荐
相关产品推荐

