手动关闭通知后,R的闪亮通知行为

问题描述

在示例here中,如果我通过单击通知框中的“ x”来关闭通知,或者等待六秒钟使其自行消失,然后再次单击“显示”按钮,则通知没有出现。

我需要单击运行removeNotification(id)的“删除”按钮,以使通知按钮再次出现。

如何获得以下行为:

  1. 通知出现并且被手动取消或消失后,单击“显示”将使其重新出现。

AND

  1. 快速单击“显示”只会产生一条通知消息。
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
    })
  }
)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...