Saj*_*ran 6 visual-studio-code htmllint angular
我正在使用visual studio代码开发angular2应用程序,我已经安装了以下扩展,
和
我有如下组件模板,
@Component({
selector: 'userprofile',
template: `
<div class="profilecontainer">
<div class="row">
<img [src]="profile.profilePic" />
<div class="row">
<h2>{{profile.firstName}} {{profile.lastName}} </h2>
<a target="_blank" href="{{profile.detailUrl}}"> View profile</a>
<a target="-blank" href="{{profile.editUrl}}">Edit profile</a>
</div>
</div>`
})
Run Code Online (Sandbox Code Playgroud)
Hml lint在vs代码上没有显示任何错误?问题是什么?
现在,你不能。
\n\n为了向 VS Code 添加额外的功能(即linting),您必须使用为其制作的扩展,不幸的是,到此答案时,还没有任何htmllintVS Code 扩展。
请注意,您共享的两个链接都是节点模块而不是扩展。使用 with npm(即npm install htmllint)安装某些东西不会使其与 VS Code 一起工作。
您可以从 VS Code 中浏览并安装扩展,如其文档中所述,如下所示:
\n\n\n\n\n单击 VS Code 一侧活动栏中的“扩展”图标或“视图:扩展”命令 (\xe2\x87\xa7\xe2\x8c\x98X) 调出“扩展”视图。
\n
如果您找不到所需的扩展程序,您有以下几种选择:
\n\n建议的替代方案:
\n\nnpm i htmlhint-ng2 -D)将其 cli 命令添加到package.json脚本中:
"scripts": {\n "lint:html": "htmlhint-ng2 src/**/*.html"\n}\nRun Code Online (Sandbox Code Playgroud)npm run lint:htmlnpm i npm-watch -D添加监视脚本和配置package.json
"watch": {\n "lint:html": "src/**/*.html"\n},\n"scripts": {\n "lint:html": "htmlhint-ng2 src/**/*.html"\n "watch": "npm-watch"\n}\nRun Code Online (Sandbox Code Playgroud)npm run watch小智 5
现在有一个官方的 HTMLHint VS Code 扩展(它取代了 Microsoft 构建的已弃用的扩展)。
https://marketplace.visualstudio.com/items?itemName=HTMLHint.vscode-htmlhint
可以将规则配置为与 HTML 中的 Angular 组件一起使用。
| 归档时间: |
|
| 查看次数: |
3544 次 |
| 最近记录: |