【发布时间】:2018-08-24 08:41:39
【问题描述】:
我希望我的 dahsboardbody 根据侧边栏中的选择进行更改。但是,我对生成的主体渲染有一个问题,如下所示:
框的宽度 = 12,因此应该像这样覆盖整个 Row:
这是我正在使用的代码:
body1 <- dashboardBody(
box(title = "test1", width = 12)
)
body2 <- dashboardBody(
box(title = "test2", width = 12)
)
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Choose", tabName = "test",
radioButtons("choice", label = NULL, choices = c("body1", "body2"))
)
)
)
body <- dashboardBody(uiOutput("body"))
ui <- dashboardPage(
header = dashboardHeader(),
sidebar = sidebar,
body = body1
)
server <- function(input, output, session) {
output$body <- renderUI({
if(input$choice == "body1") {
body1
}
else {
body2
}
})
}
shinyApp(ui, server)
调整窗口大小或在浏览器中打开它没有帮助。我错过了什么?
我正在使用 R 版本 3.5.0 (2018-04-23) 与 shinydashboard_0.7.0 和 shiny_1.1.0。
非常感谢您的帮助!
【问题讨论】:
-
您的代码非常适合我,就像正确渲染一样。
标签: r shiny rendering data-science shinydashboard