Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在RenderFragment Antd Blazor中触发@onclick_C#_.net Core_Antd_.net 5_Ant Design Blazor - Fatal编程技术网

C# 如何在RenderFragment Antd Blazor中触发@onclick

C# 如何在RenderFragment Antd Blazor中触发@onclick,c#,.net-core,antd,.net-5,ant-design-blazor,C#,.net Core,Antd,.net 5,Ant Design Blazor,我正在使用ant design blazor(.net 5.0,antblazor 0.7.4)并尝试触发@onclick按钮render by RenderFragment:App.razor @inject NavigationManager NavigationManager <Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">

我正在使用ant design blazor(.net 5.0,antblazor 0.7.4)并尝试触发@onclick按钮render by RenderFragment:App.razor

   @inject NavigationManager NavigationManager

<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(BasicLayout)" />
    </Found>
    <NotFound>
        <LayoutView Layout="@typeof(BasicLayout)">
            <Result Status="404"
                    Title="404"
                    SubTitle="Sorry, the page you visited does not exist."
                    Extra="extra" />
        </LayoutView>
    </NotFound>
</Router>
<AntContainer />
@code
{ 
    private void NavigateToHome()
    {
        NavigationManager.NavigateTo("/");
    }
    RenderFragment extra =@<Button Type="primary" @onclick="NavigateToHome">Back Home</Button>;

}
@inject NavigationManager NavigationManager

如何解决这个问题?太多了

@inject NavigationManager NavigationManager
@inject NavigationManager NavigationManager

<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(BasicLayout)" />
    </Found>
    <NotFound>
        <LayoutView Layout="@typeof(BasicLayout)">
            <Result Status="404"
                    Title="404"
                    SubTitle="Sorry, the page you visited does not exist."
                    Extra="HomeButton(NavigateToHome)" />
        </LayoutView>
    </NotFound>
</Router>
<AntContainer />
@code
{ 
    private void NavigateToHome()
    {
        NavigationManager.NavigateTo("/");
    }
    RenderFragment HomeButton(Action clickAction) => @<Button Type="primary" @onclick="@clickAction">Back Home</Button>;

}
@代码 { 私有void NavigateToHome() { NavigationManager.NavigateTo(“/”); } RenderFragment Home按钮(Action clickAction)=>@返回主页; }
添加相关标签(语言、框架、库),使您的问题更容易被社区看到谢谢@MichaelRovinsky。我编辑