1

我正在尝试使用shinyFeedback. 我使用来自shinyWidgets. 这两个似乎不能一起工作。下面是一个表示可以shinyFeedback正常工作numericInput但不能正常工作的代表autonumericInput

有什么技巧可以让这两者一起工作吗?

不良行为

library(shiny)
library(shinyWidgets)
library(shinyFeedback)

ui <- fluidPage(
  useShinyFeedback(),
  numericInput(
    "numeric_input", "numeric_input",
    value = 1e6, min = -Inf, max = Inf
  ),
  autonumericInput(
    "autonumeric_input", "autonumeric_input",
    value = 1e6, currencySymbol = "€&quot;, currencySymbolPlacement = "p", decimalPlaces = 0, digitGroupSeparator = " "
  ),
)

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

  observeEvent(input$numeric_input, {
    feedbackWarning("numeric_input", show = input$numeric_input >= 0, text = "Hello numeric_input")
  })
  
  observeEvent(input$autonumeric_input, {
    feedbackWarning("autonumeric_input", show = input$autonumeric_input >= 0, text = "Hello autonumeric_input")
  })

}

shinyApp(ui, server)
4

1 回答 1

0

这可能是解决此类问题的解决方法。

图片

library(shiny)
library(shinyWidgets)
library(tidyverse)

ui <- fluidPage(
  
  tags$head(
    tags$style(
      HTML(".shiny-notification {
             position:fixed;
             top: calc(1%);
             left: calc(1%);
             }
             "
      )
    )
  ),
  
  br(), br(), br(), br(),
  autonumericInput(
    "autonumeric_input", "autonumeric_input",
    value = 0, minimumValue = 0, maximumValue = 1, currencySymbol = "€&quot;, currencySymbolPlacement = "p", decimalPlaces = 0, digitGroupSeparator = " "
  ),
)

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

  observeEvent(input$autonumeric_input, {
    
    showNotification(duration = 1.5, "Notification", type = "warning")
    
  })

}

shinyApp(ui, server)
于 2020-12-15T16:21:28.170 回答