如何解决app.razor中的Blazor Webassembly 3.2.0预览2更新问题?

时间:2020-03-27 12:54:52

标签: blazor

我已将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    ");
            }
            ));

1 个答案:

答案 0 :(得分:2)

NewLayout1的命名空间是什么?

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

并确保在@using Admin.UI中设置了_Imports.razor