r - 在 tabItems Shiny 仪表板之间切换

标签 r tabitem shinydashboard menu-items

我正在创建一个 Shiny 的仪表板,我创建了 3 个 tabItems
问题是,当我点击其中一个 menuItem 时,我无法再次点击,我无法在 tabItems 之间切换。有人能帮助我吗
代码 R
#用户界面

 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"))

    )
)))

关于r - 在 tabItems Shiny 仪表板之间切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38925557/

相关文章:

java - 2 个 TabItem 的一个用户列表

r - 如何创建自定义 Shinydashboard 皮肤

r - 使用 includeHTML 时 sidebarMenu 无法正常工作

shinydashboard - Highcharter - 单击事件以从图表中过滤数据

r - 如何将单独的路径映射到冲积图?

r - 我可以使用 lubridate 使用 %within% 在间隔内获取多个实例吗?

ios - 如何在 SwiftUI 的 TabView 中添加底部曲线?

wpf - TabControl.Orientation?

r - 替换的意外行为

r - 如何在Windows R上设置和使用MPI