【问题标题】:How do i fix Blazor webassembly 3.2.0 preview 2 update issue in app.razor?如何修复 app.razor 中的 Blazor webassembly 3.2.0 预览 2 更新问题?
【发布时间】:2020-07-08 05:15:49
【问题描述】:

我已将我的 Blazor Web 程序集应用更新到最新的 3.2.0 预览版 2,但我无法在 App.razor 中解决此错误

错误非常简单,找不到 NewLayout1。它存在,它继承了 LayoutComponentBase 但由于某种原因 App.razor 看不到它。

我能做些什么来解决这个问题?

<Router AppAssembly="@typeof(Program).Assembly">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(NewLayout1)" />
    </Found>
    <NotFound>
        <LayoutView Layout="@typeof(NewLayout1)">
            <p>Sorry, there's nothing at this address.</p>
        </LayoutView>
    </NotFound>
</Router>

找不到类型或命名空间名称“NewLayout1”(您是 缺少 using 指令或程序集引用?)

无法将 lambda 表达式转换为预期的委托类型,因为 块中的某些返回类型不可隐式转换 到委托返回类型\Debug\netstandard2.1\Razor\App.razor.g.cs

__builder.AddAttribute(2, "Found", (Microsoft.AspNetCore.Components.RenderFragment<Microsoft.AspNetCore.Components.RouteData>)((routeData) => (__builder2) => {
                __builder2.AddMarkupContent(3, "\r\n        ");
                __builder2.OpenComponent<Microsoft.AspNetCore.Components.RouteView>(4);
                __builder2.AddAttribute(5, "RouteData", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<Microsoft.AspNetCore.Components.RouteData>(
#nullable restore
#line 3 "C:\Users\Source\Repos\Admin.Blazor.Client\Admin.UI\Client\App.razor"
                               routeData

#line default
#line hidden
#nullable disable
                ));
                __builder2.AddAttribute(6, "DefaultLayout", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<System.Type>(
#nullable restore
#line 3 "C:\Users\\Source\Repos\Admin.Blazor.Client\Admin.UI\Client\App.razor"
                                                          typeof(NewLayout1)

#line default
#line hidden
#nullable disable
                ));
                __builder2.CloseComponent();
                __builder2.AddMarkupContent(7, "\r\n    ");
            }
            ));

【问题讨论】:

标签: blazor


【解决方案1】:

NewLayout1 的命名空间是什么?

尝试在您的NewLayout1 组件中设置@namespace Admin.UI

并确保 @using Admin.UI 设置为 _Imports.razor

【讨论】:

  • 我注意到现在必须将构建操作设置为 NewLayout1 上的内容,以便 app.razor 识别它
  • 好的,这不是默认的吗?
猜你喜欢
  • 2020-07-14
  • 2020-07-18
  • 2020-09-12
  • 1970-01-01
  • 2020-06-18
  • 1970-01-01
  • 2021-04-15
  • 2020-12-13
  • 2021-10-27
相关资源
最近更新 更多