我正在R中构建一个shinydashboard(plus)应用,而dashboardHeaderPlus()
函数却遇到了问题。 dropdownBlock()
使我体内的对象(图和表)消失。即每当我注释掉标记为#### CRITICAL CODE ####
的部分时,该应用程序都会正常运行。否则,将不显示主体框中的图和表格。
问题:您能否重现该问题?为什么侧边栏对象dropdownBlock()
会干扰身体中的对象?
dashboardHeaderPlus()
函数基本上取自软件包的demo。
# packages ----------------------------------------------------------------
require(shiny)
require(shinydashboard)
require(shinydashboardPlus)
require(DT)
# ui ----------------------------------------------------------------------
header = dashboardHeaderPlus(
title = 'My app',
fixed = TRUE,
#### CRITICAL CODE ####
left_menu = tagList(
dropdownBlock(
id = 'download',
title = 'Download',
downloadButton(outputId = 'download', 'Download the data'),
downloadButton(outputId = 'download', 'Download the data')
)
),
#### END CRITICAL CODE ####
dropdownMenu(
type = "tasks",
badgeStatus = "danger",
taskItem(value = 20, color = "aqua", "Refactor code")
)
)
sidebar = dashboardSidebar(
sidebarMenu(id = 'menu',
menuItem('Item1', tabName = 'item1'))
)
body = dashboardBody(
fluidRow(
box(title = 'Box',
status = 'success',
width = 12,
collapsible = TRUE,
plotOutput(outputId = 'pl')
)
),
fluidRow(
box(title = 'Table',
status = 'primary',
dataTableOutput(outputId = 'dat'),
width = 9, offset = 0)
)
)
ui = dashboardPage(header, sidebar, body)
# server ------------------------------------------------------------------
server = function(input, output) {
output$pl = renderPlot(plot(iris$Sepal.Length ~ iris$Sepal.Width))
output$dat = renderDataTable(iris)
}
# app ---------------------------------------------------------------------
shinyApp(ui, server)