actionButton未在闪亮

时间:2018-02-16 09:23:39

标签: r button shiny eventtrigger

我不明白为什么我的actionButton没有被触发,当我点击它时什么也没发生。在尝试了几件事之后,我不知道该怎么做......

我的应用:

ui:

navbarPage("page", id = "nav",
  tabPanel("tab",

    navbarPage(title = icon("caret-right"), id = "nav",

      tabPanel("Geocodage adresse",
        fluidRow(style = "padding:20px;",
          textInput("geocod_Adress", "Adresse a geocoder:"),
          actionButton("geocod_Geocod", "Calcul des coordonnees", icon("compass")),
          verbatimTextOutput("coordonnees")
        )
      )
    )
  )
)

服务器:

function(input, output, session) {
  ntext < - eventReactive(input$geocod_Geocod, {
    return(input$geocod_Adress)
  })

  output$nText < - renderText({
    ntext()
  })
}

1 个答案:

答案 0 :(得分:0)

而不是coordonnees,它应该是nText,而不是ntext,因为您要引用renderText,而不是eventReactive 。工作示例:

library(shiny)
ui <- fluidPage(
  fluidRow(style = "padding:20px;",
           textInput("geocod_Adress", "Adresse a geocoder:"),
           actionButton("geocod_Geocod", "Calcul des coordonnees", icon("compass")),
           verbatimTextOutput("nText")
  )
)

server <-function(input, output, session) {

  ntext <- eventReactive(input$geocod_Geocod, {
    return(input$geocod_Adress)
  })

  output$nText <- renderText({
    ntext()
  })
}
shinyApp(ui,server)