R';在手动关闭通知后,s的通知行为
在本例中,如果我通过单击通知框中的“x”关闭通知,或等待六秒钟使其自行消失,然后再次单击“显示”按钮,则通知不会显示 我需要单击“删除”按钮,该按钮运行R';在手动关闭通知后,s的通知行为,r,shiny,R,Shiny,在本例中,如果我通过单击通知框中的“x”关闭通知,或等待六秒钟使其自行消失,然后再次单击“显示”按钮,则通知不会显示 我需要单击“删除”按钮,该按钮运行removeNotification(id),以使通知按钮再次出现 如何获得以下行为: 通知出现并被手动取消或消失后,单击“显示”将使其重新出现 及 快速单击“显示”只会产生一条通知消息 shinyApp( ui=fluidPage( 动作按钮(“显示”、“显示”), 操作按钮(“删除”、“删除”) ), 服务器=功能(输入、输出){ #通知ID
removeNotification(id)
,以使通知按钮再次出现
如何获得以下行为:
shinyApp(
ui=fluidPage(
动作按钮(“显示”、“显示”),
操作按钮(“删除”、“删除”)
),
服务器=功能(输入、输出){
#通知ID
id此行为是由于检查当前是否通过id
显示消息造成的。我认为他们使用它是为了不同时显示多个通知。您需要此检查吗?如果不需要,可以轻松更改代码
shinyApp(
ui = fluidPage(
actionButton("show", "Show"),
actionButton("remove", "Remove")
),
server = function(input, output) {
# A notification ID
id <- NULL
observeEvent(input$show, {
# If there's currently a notification, don't add another
if (!is.null(id))
return()
# Save the ID for removal later
id <<- showNotification(paste("Notification message"), duration = 6)
})
observeEvent(input$remove, {
if (!is.null(id))
removeNotification(id)
id <<- NULL
})
}
)