@code { private Tab? TabSetMenu { get; set; } private IEnumerable GetSideMenuItems() { return new List { new MenuItem() { Text = "计数器" }, new MenuItem() { Text = "天气预报" } }; } private async Task OnClickMenuItem(MenuItem item) { if (TabSetMenu != null) { var text = item.Text; var tabItem = TabSetMenu.Items.FirstOrDefault(i => i.Text == text); if (tabItem == null) await AddTabItem(text ?? ""); else await TabSetMenu.ActiveTab(tabItem); } } private async Task AddTabItem(string text) { var item = new TabItem(); var parameters = new Dictionary { [nameof(TabItem.Text)] = text, [nameof(TabItem.IsActive)] = true, [nameof(TabItem.ChildContent)] = text == "计数器" ? DynamicComponent.CreateComponent() : DynamicComponent.CreateComponent() }; var _ = item.SetParametersAsync(ParameterView.FromDictionary(parameters)); if (TabSetMenu != null) await TabSetMenu.Add(item); } }