我正在使用Grid.Blazor库在 Blazor 应用程序上呈现服务器端网格。其中一列有一个带有点击事件的按钮。因此,当单击按钮时,也会触发网格行事件以及按钮单击事件。我想停止事件传播,只让按钮单击事件触发。
网格:
<GridComponent @ref="_gridComponent" T="QuickLists" Grid="@_grid" OnRowClicked="@(async (item) => await ExerciseDetails(item))"></GridComponent>
Action<IGridColumnCollection<QuickExcerciseLists>> columns = c =>
{
c.Add().Titled("Actions").RenderComponentAs(typeof(ChildComponent)).SetWidth("5%");
c.Add(o => o.Name, comparer).Titled("Name").SetWidth("10%");
c.Add(o => o.Age, comparer).Titled("Age").SetWidth("15%");
c.Add(o => o.Address, comparer).Titled("Address").RenderComponentAs<MatTooltip>().SetWidth("15%");
};
自定义列组件:
<MatBlazor.MatButton Icon="@MatIconNames.Remove_red_eye" @onclick="@ShowData" @onclick:stopPropagation="true"></MatBlazor.MatButton>
我尝试传入@onclick:stopPropagation
子按钮组件。但它在下面给出了编译错误。
组件参数“onclick”用于该组件两次或多次。参数必须是唯一的(不区分大小写)。组件参数“onclick”由“@onclick:stopPropagation”指令属性生成。
我正在运行.Net core 3.1.201。非常感谢任何帮助。