图片未显示在闪亮的仪表板的infoBox中

时间:2018-10-31 07:29:57

标签: r shiny

我找不到错误的图片,为什么图片没有显示在infoBox ShinyApp内。

library(shiny)
library(shinydashboard)
a <- 45

ui <-   shinyUI(
dashboardPage(
dashboardHeader(title = "ABC"),
dashboardSidebar(),
dashboardBody(
  fluidPage(
    infoBox("BCD", a, div(img(src = "img.png", width = 100), style = "text- 
align: center;"))
  )
)
)
)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

2 个答案:

答案 0 :(得分:0)

以下内容对我有用:

  1. 将上述脚本另存为app.R
  2. app.R文件夹中,创建一个名为www的文件夹,并将img.png保存在其中
  3. 点击RStudio上的 Run App 按钮(右上方)

答案 1 :(得分:0)

您可能想看看addResourcePath函数以获得更灵活的解决方案:

http://shiny.rstudio.com/reference/shiny/0.14/addResourcePath.html