闪亮:如何在禁用操作按钮的情况下启动应用程序?

Shiny: how to start application with action button disabled?

我需要在禁用“button2”的情况下启动应用程序。它只能在按下“button1”后启用。我该怎么做?

我正在尝试使用 shinyjs 包中的 enable/disable。

我可以在按下“button1”后启用“button2”,但是如何在禁用“button2”的情况下启动应用程序?

     observeEvent(input$b1,{
        shinyjs::enable("b2")
        ... 
     })

您可以在 UI 定义中使用 disabled :

library(shinyjs)
ui = fluidPage(
      useShinyjs(),  # Set up shinyjs
      disabled(actionButton("b2", "Click me")),
      ...
    )

另一种选择是按照Hadley's answer:

ui = fluidPage(
      useShinyjs(),  # Set up shinyjs
      actionButton("b2", "Click me",disabled=''),
      ...
    )

要重新激活按钮,shinyjs::enable 两个选项都有效