简体   繁体   English

Angular 10 Visual Studio Code 中 HTML 组件中的“未找到...的定义”

[英]Angular 10 “No definition found for …” in HTML component in Visual Studio Code

I'm working with angular 10 in VSCode and everything was working fine until today.我正在使用 VSCode 中的 angular 10 ,直到今天一切正常。 Suddenly I can't go to definition from HTML component neither via F12, right click - Go to definition nor Ctrl+click.突然,我无法通过 F12 从 HTML 组件定义 go 定义,也不能通过 F12 右键单击 - Go 定义或 Ctrl+单击。

Go to definition works just on typescript components, also I don't get any errors except "No definition found for...." Go 的定义仅适用于 typescript 组件,除了“没有找到...的定义”之外,我没有收到任何错误

I've tried updating VS Code, reinstalling VS Code and reinstalling extensions: Angular Essentials by John Papa Angular Language Service Angular Snippets我试过更新 VS Code,重新安装 VS Code 并重新安装扩展: Angular Essentials by John Papa Angular 语言服务 Angular Snippets

Also I experience the same behavior on all of my projects (two of them).此外,我在所有项目(其中两个)上都遇到了相同的行为。

Thanks!谢谢!

In my case, after several tries, I found the cause was an * ngIf="whatever" in the parent DOM element and in some other cases in other elements in the same level, after removing this, all definitions were reachable again... this is a bug As a workaround, I downgraded Angular Language Service to 11.2.0在我的情况下,经过几次尝试,我发现原因是父 DOM 元素中的 * ngIf="whatever"以及在其他一些情况下在同一级别的其他元素中,删除它后,所有定义都可以再次访问......这是一个错误作为一种解决方法,我将 Angular 语言服务降级到 11.2.0

work for me....为我工作......

To enable the latest Language Service features, set the strictTemplates option in tsconfig.json by setting strictTemplates to true, as shown in the following example:要启用最新的语言服务功能,请通过将 strictTemplates 设置为 true 来设置 tsconfig.json 中的 strictTemplates 选项,如下例所示:

content_copy "angularCompilerOptions": { "strictTemplates": true } content_copy "angularCompilerOptions": { "strictTemplates": true }

https://angular.io/guide/language-service https://angular.io/guide/language-service

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Visual Studio Code 中转到角度 html 文件中的定义 - Go To Definition in angular html file in Visual Studio Code Angular 2 组件-“找不到...的定义” - Angular 2 Component - "No definition found for ..." 如何从 Angular 组件标记重定向到它在 Visual Studio 中的定义? - How to redirect from an Angular component markup to its definition in Visual Studio? 无法在Visual Studio Code中创建角度组件 - Cannot create angular component in Visual Studio Code 未定义 fetchCompletion 中的错误 - Angular 10 Visual Studio 代码 - ERROR in fetchCompletion is not defined - Angular 10 visual studio code Visual Studio Code:Angular 项目中的“找不到‘tslib’”错误 - Visual Studio Code: "'tslib' cannot be found" error in Angular project Intellisense绑定是否可以在带有Visual Studio Code的Angular中使用html? - Does intellisense for binding works in html with visual studio code for angular? 为什么 Visual Studio Code 会更改我的 Angular html? - Why is Visual Studio Code altering my Angular html? Visual Studio中的Angular 6组件声明编译器错误 - Angular 6 Component Declaration compiler error in Visual Studio Angular Visual Studio删除嵌套组件 - Angular Visual Studio Delete Nested Component
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM