在有光泽的modalDialog中插入一个新行

Bev*_*ine 5 r popup shiny

在我的闪亮应用程序中,我希望有一个带有一些文本的弹出窗口.为了使文本更具可读性,我想包含一些换行符,但到目前为止我失败了.知道我该怎么做?我目前正在使用modalDialog()

 ui = basicPage(
actionButton("show", "Show modal dialog")
),
server = function(input, output) {
observeEvent(input$show, {
  showModal(modalDialog(
    title = "My text",
    "This is the first line. 
     This should be the second."
  ))
})
}
Run Code Online (Sandbox Code Playgroud)

我试过了:br(),\n和那些的几种变体.没有任何效果.

救命!!!

Big*_*ist 11

您可以将其包装HTML()然后使用<br>,类似于上面提到的尝试.所以你可以改用:HTML("This is the first line.<br> This should be the second.")

有关完整的应用,请参阅以下内容:

ui = basicPage(
  actionButton("show", "Show modal dialog")
)
server = function(input, output) {
  observeEvent(input$show, {
    showModal(modalDialog(
      title = "My text",
      HTML("This is the first line.<br> 
      This should be the second.")
    ))
  })
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)