Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R';在手动关闭通知后,s的通知行为_R_Shiny - Fatal编程技术网

R';在手动关闭通知后,s的通知行为

R';在手动关闭通知后,s的通知行为,r,shiny,R,Shiny,在本例中,如果我通过单击通知框中的“x”关闭通知,或等待六秒钟使其自行消失,然后再次单击“显示”按钮,则通知不会显示 我需要单击“删除”按钮,该按钮运行removeNotification(id),以使通知按钮再次出现 如何获得以下行为: 通知出现并被手动取消或消失后,单击“显示”将使其重新出现 及 快速单击“显示”只会产生一条通知消息 shinyApp( ui=fluidPage( 动作按钮(“显示”、“显示”), 操作按钮(“删除”、“删除”) ), 服务器=功能(输入、输出){ #通知ID

在本例中,如果我通过单击通知框中的“x”关闭通知,或等待六秒钟使其自行消失,然后再次单击“显示”按钮,则通知不会显示

我需要单击“删除”按钮,该按钮运行
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
        })
      }
    )