如何在闪亮的 observeEvent 中监听多个动作按钮以重新加载闪亮

How to listen for more than one actionbutton within a Shiny observeEvent to reload shiny

问题来了,我有两个动态呈现的操作按钮,旨在重新加载会话,但我无法听到它们,它就像一个 OR 操作,点击每个按钮然后会话重新加载.这是代码:

ui <- shinyUI(bootstrapPage(
  p('cbldwbvkdj'),
  uiOutput('aa')
  )
)

server <- shinyServer(function(input, output, session) {
  output$aa<-renderUI({
    actionButton("test1", "test1")
    actionButton("test2", "test2")
  })
  observeEvent(paste0(input$test1, input$test2), {
    session$reload()
  }, ignoreInit = T)
})

shinyApp(ui, server)

您可以将 req 添加到 observeEvent:

library(shiny)
ui <- shinyUI(
    bootstrapPage(
        p('cbldwbvkdj'),
        uiOutput('aa')
    )
)

server <- shinyServer(function(input, output, session) {
    
    output$aa <- renderUI({
        tagList(
            actionButton("test1", "test1"),
            actionButton("test2", "test2")
        )
    })
    
    observeEvent(list(input$test1, input$test2),{
        req(input$test1!=0 | input$test2 !=0)
        session$reload()
    }, ignoreInit = TRUE,ignoreNULL = TRUE)
})

shinyApp(ui, server)