代码之家  ›  专栏  ›  技术社区  ›  epam employee

renderUI不适用于fillPage

  •  1
  • epam employee  · 技术社区  · 6 年前

    我有以下简单的工作闪亮应用程序:

    if (interactive()) {
        ui <- fillPage(
            fillRow(
                fillCol(".", style = "background-color: red;", height = "10%"),
                fillCol(".", style = "background-color: blue;", height = "10%")
            )
        )
        server <- function(input, output, session) {}
        shinyApp(ui, server)
    }
    

    结果正是我想要的,但如果我想用 renderUI 我得到一个空白页。

    我尝试使用以下代码:

    if (interactive()) {
        ui <- fillPage(
            uiOutput("back")
        )
        server <- function(input, output, session) {
            output$back <- renderUI({
                fillRow(
                    fillCol(".", style = "background-color: red;", height = "10%"),
                    fillCol(".", style = "background-color: blue;", height = "10%")
                )
            })
        }
        shinyApp(ui, server)
    }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Bertil Baron    6 年前

    这是使用时的典型问题 height:100% 。使用uiOutput会在您的周围添加一个div renderUI 不幸的是,这个div的默认高度是0。修正将高度设置为 100% 对于这个部门也是如此。

    if (interactive()) {
      ui <- fillPage(
        uiOutput("back",style = "height:100%;")
      )
      server <- function(input, output, session) {
        output$back <- renderUI({
          fillRow(
            fillCol(".", style = "background-color: red;", height = "10%"),
            fillCol(".", style = "background-color: blue;", height = "10%")
          )
        })
      }
      shinyApp(ui, server)
    }
    

    希望这有帮助!