我正在创建一个闪亮的dashbord,我创建了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"))
)
)))
最佳答案
我知道您的问题已经解决,并且大约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"))
)
)))