menuItem 周围的 ConditionalPanel 无法正确显示
ConditionalPanel around menuItem Doesn't Display Properly
如何将 menuitem
包装在条件面板中,使其看起来像其余的菜单项?
尝试单击 B 并查看 C 菜单项与菜单项 A 或 B 相比的外观 -
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome")),
conditionalPanel("input.sidebarmenu === 'b'",
sliderInput("b", "Under sidebarMenu", 1, 100, 50)
),
conditionalPanel("input.sidebarmenu === 'b'",
menuItem("C", tabName = "c", icon = icon("check-circle", lib = "font-awesome"))
)
)
),
dashboardBody()
)
server <- function(input, output) {}
shinyApp(ui, server)
(大部分代码借鉴自 - https://github.com/rstudio/shinydashboard/issues/28)
我希望解决方案不需要修改 CSS 或其他一些背景设置。
有效的解决方案是再次将 menuItem
包裹在 sidebarMenu( )
中
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome")),
conditionalPanel("input.sidebarmenu === 'b'",
sliderInput("b", "Under sidebarMenu", 1, 100, 50)
),
conditionalPanel("input.sidebarmenu === 'b'",
sidebarMenu(menuItem("C", tabName = "c", icon = icon("check-circle", lib = "font-awesome")))
)
)
),
dashboardBody()
)
server <- function(input, output) {}
shinyApp(ui, server)
然而,在做了一些研究后,我不明白为什么这是必要的(我想知道它是否与 this issue 有某种关系?
如果有人有详细的解释,我将不胜感激:)
实际上,在@tospig 的解决方案中,活动菜单项的突出显示效果不佳。我发现这没有任何问题:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
conditionalPanel("input.sidebarmenu == 'b'",
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome")),
sliderInput("b", "Under sidebarMenu", 1, 100, 50)
menuItem("C", tabName = "c", icon = icon("check-circle", lib = "font-awesome"))
)
),
conditionalPanel("input.sidebarmenu != 'b'",
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome"))
)
)
),
dashboardBody()
)
server <- function(input, output) {}
shinyApp(ui, server)
如何将 menuitem
包装在条件面板中,使其看起来像其余的菜单项?
尝试单击 B 并查看 C 菜单项与菜单项 A 或 B 相比的外观 -
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome")),
conditionalPanel("input.sidebarmenu === 'b'",
sliderInput("b", "Under sidebarMenu", 1, 100, 50)
),
conditionalPanel("input.sidebarmenu === 'b'",
menuItem("C", tabName = "c", icon = icon("check-circle", lib = "font-awesome"))
)
)
),
dashboardBody()
)
server <- function(input, output) {}
shinyApp(ui, server)
(大部分代码借鉴自 - https://github.com/rstudio/shinydashboard/issues/28)
我希望解决方案不需要修改 CSS 或其他一些背景设置。
有效的解决方案是再次将 menuItem
包裹在 sidebarMenu( )
中
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome")),
conditionalPanel("input.sidebarmenu === 'b'",
sliderInput("b", "Under sidebarMenu", 1, 100, 50)
),
conditionalPanel("input.sidebarmenu === 'b'",
sidebarMenu(menuItem("C", tabName = "c", icon = icon("check-circle", lib = "font-awesome")))
)
)
),
dashboardBody()
)
server <- function(input, output) {}
shinyApp(ui, server)
然而,在做了一些研究后,我不明白为什么这是必要的(我想知道它是否与 this issue 有某种关系?
如果有人有详细的解释,我将不胜感激:)
实际上,在@tospig 的解决方案中,活动菜单项的突出显示效果不佳。我发现这没有任何问题:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
conditionalPanel("input.sidebarmenu == 'b'",
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome")),
sliderInput("b", "Under sidebarMenu", 1, 100, 50)
menuItem("C", tabName = "c", icon = icon("check-circle", lib = "font-awesome"))
)
),
conditionalPanel("input.sidebarmenu != 'b'",
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome"))
)
)
),
dashboardBody()
)
server <- function(input, output) {}
shinyApp(ui, server)