事件回调后执行函数

do function after event call back

我尝试在回调函数中调用子组件中的函数。

在我的子组件中:

<div class="container">
<h1 class="text-center">DUO BUSINESS</h1><i class="fal @IcoMenu" @onclick="CollapseMenu"></i>

@code{

        [Parameter]
        public EventCallback CollapseMenu { get; set; }

public void Popover()
    {
        Console.WriteLine("test");
    }
}

在我的父组件中:

     private void CollapseMenu()
    {
        if (collapseMenu == "vxs-left-side-menu")
        {
            this.collapseMenu = "vxs-left-side-menu vxs-left-side-menu-collapse";
            this.icoMenu = "fa-yin-yang";
        }
        else
        {
            this.collapseMenu = "vxs-left-side-menu";
            this.icoMenu = "fa-times";

------------HERE I WANT TO DO A FUNCTION IN CHILD COMPONENT------------
              Do popoverFunction in child component

        }
    }

好的,我找到答案了:

在子组件中:

<div class="container">
    <h1 class="text-center">DUO BUSINESS</h1><i class="fal @IcoMenu" @onclick="Popover"></i>
</div>

    @code{

        [Parameter]
        public EventCallback CollapseMenu { get; set; }   


        public void Popover()
        {
            vxsMenuCollapsePopover = new string[5];
            CollapseMenu.InvokeAsync(true);
        }
    }

在父组件中:

<div class="@collapseMenu">
        <NavMenu CollapseMenu="@CollapseMenu" IcoMenu="@icoMenu"/>
    </div>

 private void CollapseMenu()
    {
        if (collapseMenu == "vxs-left-side-menu")
        {
            this.collapseMenu = "vxs-left-side-menu vxs-left-side-menu-collapse";
            this.icoMenu = "fa-yin-yang";
        }
        else
        {
            this.collapseMenu = "vxs-left-side-menu";
            this.icoMenu = "fa-times";
        }
    }

它现在对我有用如果你有更好的建议告诉我,谢谢!