@code { private static IEnumerable GetItems() { var ret = new List { new TreeItem() { Text = "导航一" }, new TreeItem() { Text = "导航二" }, new TreeItem() { Text = "导航三" } }; ret[1].AddItem(new TreeItem() { Text = "子菜单一" }); ret[1].AddItem(new TreeItem() { Text = "子菜单二" }); ret[1].AddItem(new TreeItem() { Text = "子菜单三" }); ret[1].Items.ElementAt(0).AddItem(new TreeItem() { Text = "孙菜单1一" }); ret[1].Items.ElementAt(0).AddItem(new TreeItem() { Text = "孙菜单1二" }); ret[1].Items.ElementAt(1).AddItem(new TreeItem() { Text = "孙菜单2一" }); ret[1].Items.ElementAt(1).AddItem(new TreeItem() { Text = "孙菜单2二" }); ret[1].Items.ElementAt(1).Items.ElementAt(1).AddItem(new TreeItem() { Text = "曾孙菜单一" }); ret[1].Items.ElementAt(1).Items.ElementAt(1).AddItem(new TreeItem() { Text = "曾孙菜单二" }); ret[1].Items.ElementAt(1).Items.ElementAt(1).Items.ElementAt(1).AddItem(new TreeItem() { Text = "曾曾孙菜单一" }); ret[1].Items.ElementAt(1).Items.ElementAt(1).Items.ElementAt(1).AddItem(new TreeItem() { Text = "曾曾孙菜单二" }); return ret; } private IEnumerable Items { get; set; } = GetItems(); }