我正在使用Dean的shinyalert包中的示例:
库(闪亮)库(shinyalert)
shinyApp(ui = fluidPage(useShinyalert(),#设置shinyalertactionButton(“btn”,“Greet”) )
服务器……
我想你必须使用:
callbackR = function(value) { shinyalert(paste("Welcome", value))}
它也可能是文件中显示的内容: https://github.com/daattali/shinyalert#chaining 。
你的代码 message("Hello ", x) ,实际上按设计工作,因为它将消息打印到控制台。
message("Hello ", x)
完整代码如下:
library(shiny) library(shinyalert) shinyApp( ui = fluidPage( useShinyalert(), # Set up shinyalert actionButton("btn", "Greet") ), server = function(input, output) { observeEvent(input$btn, { shinyalert( "Enter your name", type = "input", callbackR = function(value) { shinyalert(paste("Welcome", value))}, callbackJS = "function(x) { alert('Hello ' + x); }" ) }) } )