我有一个按钮:
<BSButton Color="Color.Info" @onclick="LoadCategoryDetailsModal">
<i class="fal fa-plus-circle mr-1"></i>Add New Category
</BSButton>
我有一个组件:
<CategoryDetails CategoryDetailModalTitle="@categoryDetailModalTitle">
</CategoryDetails>
在组件中,我有一个切换模式(显示/隐藏)的功能;模态默认隐藏
@using BlazingShop.Services
@inject ICategoryService CategoryService
<BSModal @ref="CategoryDetailsModal" IsCentered="true">
<BSModalHeader OnClick="@OnToggle">@CategoryDetailModalTitle</BSModalHeader>
<BSModalBody><p>Modal body text goes here.</p></BSModalBody>
<BSModalFooter>
<BSButton Color="Color.Primary">Save Changes</BSButton>
<BSButton Color="Color.Secondary" @onclick="@OnToggle">Close</BSButton>
</BSModalFooter>
</BSModal>
@code {
BSModal CategoryDetailsModal;
[Parameter]
public string CategoryDetailModalTitle { get; set; }
void OnToggle(MouseEventArgs e)
{
CategoryDetailsModal.Toggle();
}
}
我尝试从父组件切换模式。
你能帮我吗 ?
当我单击此按钮(在父组件中)时:
<BSButton Color="Color.Info" @onclick="LoadCategoryDetailsModal">
<i class="fal fa-plus-circle mr-1"></i>Add New Category
</BSButton>
我想在子组件中使用这个函数:
CategoryDetailsModal.Toggle();