Shiny withSpinner隐藏或切换

问题描述 投票:0回答:1

我还没有做出选择时,一开始试图隐藏微调框。这是到目前为止我所取得成就的简单示例。

library(shinycssloaders)

ui <- fluidPage(
  selectInput(inputId = "something",
            label = "Select something:",
            choices = c('','None', 'All', 'Some'),
            selected = ''),
  withSpinner(textOutput(outputId = "text")  )
)

server <- function(input, output) {
  observe({
    toggle(id = 'text', condition = F)

    if(nchar(input$something) > 0 ){
      toggle(id = 'text', condition = T)
      Sys.sleep(1)
      output$text <- renderText(paste("You chose ",input$something))
    }
  })
}

shinyApp(ui,server)

更改选项后,微调器会正确显示。不幸的是,一开始切换似乎只在文本上起作用,而不是微调框本身。我也尝试过用户界面中的withSpinner(textOutput(outputId = "text") , id = 'myspin' )和服务器中的toggle(id = 'myspin', condition = F),但还没有运气。 hide(id = 'text')似乎也没有任何作用。

r shiny toggle hide
1个回答
1
投票

您可以在开始时隐藏容器,然后再次启用它

© www.soinside.com 2019 - 2024. All rights reserved.