简体   繁体   English

shiny 中带有 verbatimTextOutput 的参数类型无效

[英]Invalid argument type with verbatimTextOutput in shiny

I am having a very difficult time getting to understand how Shiny modules work.我很难理解 Shiny 模块的工作原理。 I am building an app using a Golem template ( https://github.com/ThinkR-open/golem ).我正在使用 Golem 模板 ( https://github.com/ThinkR-open/golem ) 构建应用程序。

Edit I realized that my error was not tied to any modules, so generated a minimal example.编辑我意识到我的错误与任何模块无关,因此生成了一个最小的示例。 To review the old code, look in the edit history要查看旧代码,请查看编辑历史记录

library(shiny)

app_ui <- function() {
  fluidPage(
    textInput(inputId = "test", label = "Labley", value = "val"),
    verbatimTextOutput(outputId = "out", placeholder = "None")
  )
}

app_server <- function(input, output, session) {
  output$out <- renderText(expr = input$test)
}

shinyApp(ui = app_ui, server = app_server)

This causes:这引起:

Error in !: invalid argument type

How do I get UI to print my text input?如何让 UI 打印我的文本输入?

@KasperThystrupKarstensen the problem here is, that verbatimTextOutput 's placeholder argument requires a boolean input (see usage in ?verbatimTextOutput ). @KasperThystrupKarstensen 这里的问题是, verbatimTextOutput的占位符参数需要 boolean 输入(参见?verbatimTextOutput中的用法)。 However, you passed a string.但是,您传递了一个字符串。

This works:这有效:

library(shiny)

app_ui <- fluidPage(
  textInput(
    inputId = "test",
    label = "Labley",
    value = "val"
  ),
  verbatimTextOutput(outputId = "out", placeholder = FALSE)
)

app_server <- function(input, output, session) {
  output$out <- renderText(expr = input$test)
}

shinyApp(ui = app_ui, server = app_server)

?verbatimTextOutput : ?verbatimTextOutput

placeholder: if the output is empty or NULL, should an empty rectangle be displayed to serve as a placeholder?占位符:如果 output 为空或 NULL,是否应该显示一个空矩形作为占位符? (does not affect behavior when the the output in nonempty) (不影响 output 为非空时的行为)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM