R Shiny:在modalDialog中包含图像

问题描述 投票:0回答:1

我想在modalDialog中显示图像,但R不会渲染一个。

以下代码仅显示指向Google徽标的链接,但不显示Google徽标本身的链接:

Server.R:

observeEvent(input$button, {
    showModal(modalDialog(
      title = "Title",
      '<img>https://www.google.nl/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png</img>',
      easyClose = TRUE,
      footer = NULL
    ))
  })

长子。 [R

actionButton(inputId ="button", label = "Click me")
r shiny
1个回答
2
投票
      observeEvent(input$button, {
        showModal(modalDialog(
          title = "Title",
          HTML('<img src="http://www.google.nl/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">'),
          easyClose = TRUE,
          footer = NULL
        ))

  })

您的HTML中有错误。使用HTML(...)标记指定html代码,然后在<img>标记中指定源代码。上面的代码适合我。

© www.soinside.com 2019 - 2024. All rights reserved.