【问题标题】:Add link to external URL in sidebarmenu dashboard在侧边栏菜单仪表板中添加指向外部 URL 的链接
【发布时间】:2020-09-12 01:11:43
【问题描述】:

希望你能帮助我。有没有办法在闪亮仪表板的侧边栏菜单中添加超链接?我使用以下代码进行了尝试:


ui <- dashboardPage(

  dashboardHeader(title = "Co-Lock App"),
  dashboardSidebar(
    sidebarMenu(
      id = "tabs",
      menuItem("Manual", tabName = 'manual', icon = icon("book-reader")),
      menuItem("Tumor Cell Expression", tabName =  "known", icon = icon("check-double")),
      menuItem("Immune Cell Expression", tabName = "immune", icon = icon("check-double")),
      menuItem("Tumor Cell Targets", tabName = "target", icon = icon("bullseye")),
      menuItem("Immune Cell Targets", tabName = "immunetarget", icon = icon("bullseye")),
      menuItem("Perfect Match", tabName = "match", icon = icon("heart")),
      menuItem(uiOutput("png"))
    )
  ),
  dashboardBody())

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

  output$png <- renderUI({
    tags$a(img(src = "ccle.png"), href = "https://www.ebi.ac.uk/gxa/experiments/E-MTAB-2770/Results", target = "_blank")
  })

}

shinyApp(ui = ui, server = server)

虽然链接有效,但 png 图像很大,当我尝试调整宽度和高度时,没有任何变化。反正有这个吗?

谢谢!

【问题讨论】:

  • 可以发一下ui代码吗
  • menuItem(uiOutput("png")) 这是侧边栏菜单中的代码
  • 贴出截断的整个代码,这样我可以复制粘贴并重现问题
  • 我编辑了问题中的代码。感谢您的帮助!
  • @PorkChop,您是否设法重现该问题?

标签: r shiny hyperlink dashboard sidebar


【解决方案1】:

较老的问题,但我想我会分享一个代码更改最少的解决方案。

解决方案:在图片标签内添加width = "50px"您可能需要调整尺寸以使其正确

我在上面的代码中没有图像,所以我用自己的图像尝试了这个,它成功了。以下是建议解决方案的原始代码:

ui <- dashboardPage(

  dashboardHeader(title = "Co-Lock App"),
  dashboardSidebar(
    sidebarMenu(
      id = "tabs",
      menuItem("Manual", tabName = 'manual', icon = icon("book-reader")),
      menuItem("Tumor Cell Expression", tabName =  "known", icon = icon("check-double")),
      menuItem("Immune Cell Expression", tabName = "immune", icon = icon("check-double")),
      menuItem("Tumor Cell Targets", tabName = "target", icon = icon("bullseye")),
      menuItem("Immune Cell Targets", tabName = "immunetarget", icon = icon("bullseye")),
      menuItem("Perfect Match", tabName = "match", icon = icon("heart")),
      menuItem(uiOutput("png"))
    )
  ),
  dashboardBody())

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

  output$png <- renderUI({
    tags$a(img(src = "ccle.png", width = "20px"), href = "https://www.ebi.ac.uk/gxa/experiments/E-MTAB-2770/Results", target = "_blank")
  })

}

shinyApp(ui = ui, server = server)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-18
    • 2016-05-15
    • 2020-12-15
    • 2018-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多