【问题标题】:How I can Load another Razor Component into a Razor Component by a Button-click?如何通过单击按钮将另一个 Razor 组件加载到 Razor 组件中?
【发布时间】:2020-05-17 10:59:19
【问题描述】:

我只想在用户单击搜索按钮时将剃须刀组件加载到另一个剃须刀组件中,然后我想在用户单击隐藏按钮时将搜索剃须刀组件(页面)显示到隐藏的 div 中,然后它将被隐藏。像内联弹出窗口。

【问题讨论】:

    标签: c# asp.net-core blazor blazor-server-side matblazor


    【解决方案1】:

    像这样:

    主要组件:

    @page "/test"
    
    
    <button @onclick="(() => ShowComponent = true)">Show</button>
    <button @onclick="(() => ShowComponent = false)">Hide</button>
    @if (ShowComponent)
    {
        <ShowHideComponent></ShowHideComponent>
    }
    
    
    @code {
        bool ShowComponent { get; set; } = false;
    }
    

    ShowHideComponent.razor:

    <div>Show Or Hide This</div>
    

    【讨论】:

      猜你喜欢
      • 2019-12-18
      • 2018-01-08
      • 1970-01-01
      • 2021-08-21
      • 1970-01-01
      • 2021-08-29
      • 1970-01-01
      • 2019-08-06
      • 1970-01-01
      相关资源
      最近更新 更多