这对于您的示例应该有效。您必须以某种方式创建一个数据表,只是包含它不会将其呈现为表。
注意:我把手风琴的ID改成了
Data-mtcars
. 使用空格“:”或“;”将禁用折叠。
library(shiny)
library(bsplus)
library(DT)
ui <- fluidPage(
bs_accordion(id ="Data-mtcars") %>%
bs_set_opts(panel_type = "primary", use_heading_link = T) %>%
bs_append(title = "Head of mtcars", content = DT::dataTableOutput("table1")) %>%
bs_set_opts(panel_type = "primary", use_heading_link = T) %>%
bs_append(title = "Tail of mtcars", content = DT::dataTableOutput("table2"))
)
server <- function(input, output) {
output$table1 <- DT::renderDataTable({
head
})
output$table2 <- DT::renderDataTable({
tail
})
}
shinyApp(ui, server)