Asm*_*sma 3 r menu-items tabitem shinydashboard
我正在创建一个闪亮的仪表板,我创建了 3 个 tabItems 问题是,当我单击其中一个 menuItem 时,我无法再次单击,我无法在 tabItems 之间切换。有人可以帮我请代码 R #UI
library(shiny)
library(shinydashboard)
shinyUI(dashboardPage(skin = "black",
dashboardHeader(title = h4("Tableau de bord des élections",style = "color:navy"),
titleWidth = 300
),
dashboardSidebar(id="",
menuItem(h4(strong("Dashboard", align = "center")), tabName = "dashboard"),
menuItem(h4(strong("Prédiction")), tabName = "Prédiction"),
menuItem(h4(strong("Interprétation")), tabName = "Interprétation")),
dashboardBody(
tabItems(
tabItem(tabName = "dashboard",h2("Analyse du comportement électoral des citoyens tunisiens", align="center",style = "color:navy") ),
tabItem(tabName = "Prédiction", h2("Prédiction du vote", align="center",style = "color:blue")),
tabItem(tabName = "Interprétation", h2("Interprétation"))
)
)))
Run Code Online (Sandbox Code Playgroud)
我知道您的问题已经解决,并且您可能不会在大约 1 年后更改您的代码,但是对于像我这样遇到此问题的其他人,我有一个更简单的解决方案。
您必须将所有“menuItem”包装在 sideBarMenu() 函数中。这将解决问题并使菜单中的项目更大。
library(shiny)
library(shinydashboard)
shinyUI(dashboardPage(skin = "black",
dashboardHeader(title = h4("Tableau de bord des élections",style =
"color:navy"),
titleWidth = 300
),
dashboardSidebar(id="", sidebarMenu(
menuItem(h4(strong("Dashboard", align = "center")), tabName = "dashboard"),
menuItem(h4(strong("Prédiction")), tabName = "Prédiction"),
menuItem(h4(strong("Interprétation")), tabName = "Interprétation"))),
dashboardBody(
tabItems(
tabItem(tabName = "dashboard",h2("Analyse du comportement électoral des citoyens tunisiens", align="center",style = "color:navy") ),
tabItem(tabName = "Prédiction", h2("Prédiction du vote", align="center",style = "color:blue")),
tabItem(tabName = "Interprétation", h2("Interprétation"))
)
)))
Run Code Online (Sandbox Code Playgroud)