编译正常的新 Blazor 项目的 .cshtml 中的 Visual Studio 错误?如何禁用它?

Axe*_*lly 6 c# visual-studio blazor visual-studio-2019

我刚刚通过创建了新的 blazor 项目

dotnet new blazorhosted

并打开FetchData.cshtml,但 VS 向我抛出了 9 个错误。

当然,整个项目正在编译并且工作正常,但是很烦人

如何禁用显示.cshtml文件错误?

Visual Studio 2019 预览版

Severity    Code    Description Project File    Line    Suppression State
Error   CS0103  The name 'forecasts' does not exist in the current context  Blazor.Client   FetchData.cshtml    27  Active

Error   CS0115  'Template.ExecuteAsync()': no suitable method found to override Blazor.Client   FetchData.cshtml    1   Active

Error   CS0229  Ambiguity between 'Template.__o' and 'Template.__o' Blazor.Client   FetchData.cshtml    1   Active

Error   CS0229  Ambiguity between 'Template.__o' and 'Template.__o' Blazor.Client   FetchData.cshtml    1   Active

Error   CS0229  Ambiguity between 'Template.__o' and 'Template.__o' Blazor.Client   FetchData.cshtml    1   Active

Error   CS0103  The name 'page' does not exist in the current context   Blazor.Client   FetchData.cshtml    4   Active

Error   CS0103  The name 'inject' does not exist in the current context Blazor.Client   FetchData.cshtml    5   Active

Error   CS0103  The name 'forecasts' does not exist in the current context  Blazor.Client   FetchData.cshtml    11  Active

Error   CS0103  The name 'functions' does not exist in the current context  Blazor.Client   FetchData.cshtml    37  Active
Run Code Online (Sandbox Code Playgroud)

Joh*_*ohn 1

有时 Blazor 会对我大发雷霆,并在没有错误的行上抛出错误,就像这样。

我关闭文件,清理整个解决方案,重新启动计算机,然后仅重建我正在处理的项目,然后它就消失了。

也许这对你也有用。