在“闪亮”信息中心的菜单项中访问元素

时间:2019-03-13 18:12:38

标签: shinydashboard shiny-reactivity

我需要使用子元素进行侧边栏菜单。当菜单项不包含任何子项时,仪表板将按预期运行,如以下代码所示:

library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(
    title = "Shiny"
  ),

  dashboardSidebar(
    sidebarMenu(  
      menuItem("About",tabName="A",fluidRow(column(12, p("plot1")))),
      menuItem("Second",tabName="B")

  )),

  dashboardBody(
    tabItems(
      tabItem(tabName = "Asd",fluidRow(column(12, plotOutput("plot1")))),
      tabItem(tabName = "B",fluidRow(column(12, p("HI"))))

  )))

server <- function(input, output) {
  output$plot1 <- renderPlot({
    plot(mtcars$wt, mtcars$mpg)
  })
  output$plot2 <- renderPlot({
    plot(mtcars$wt, mtcars$wt)
  })
}

shinyApp(ui,server)

但是,如果我将侧边栏菜单的第一项更改为以下内容:

menuItem("About",tabName="A",fluidRow(column(12, p("plot1")))),

我无法渲染图或在菜单选项之间进行更改。

关于如何解决此问题的任何建议?

0 个答案:

没有答案