r-如何在shinydashboard中显示背景色框中的数据表



我想把我的数据表放在我闪亮的仪表板的一个盒子里。我把我的盒子背景颜色设置为绿色。但是,我发现我的数据表内容没有显示在框中。有人知道如何解决这个问题吗?谢谢

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
dashboardHeader(title = "example"),
dashboardSidebar(),
dashboardBody(
box(width=6, background = 'green',
DT::dataTableOutput('table') 
)
)
)
server <- function(input, output, session) {
output$table <- DT::renderDataTable({
DT::datatable(iris)
})
}    

shinyApp(ui, server)

这只是字体颜色的问题:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
dashboardHeader(title = "example"),
dashboardSidebar(),
dashboardBody(
box(width=6, background = 'green',
DT::dataTableOutput('table') 
)
)
)
server <- function(input, output, session) {
output$table <- DT::renderDataTable({
df <- iris
DT::datatable(df) %>% 
# rowid is a column as well, therefore zero to nrow()
DT::formatStyle(0:nrow(df), color = "black")
})
}    

shinyApp(ui, server)

最新更新