【问题标题】:How to include an action link into a button's label?如何将操作链接包含到按钮的标签中?
【发布时间】:2019-06-23 21:03:30
【问题描述】:

我的目标是在selectInput 按钮的标签中包含一个操作链接(显示帮助文本)。

library(shiny)

ui <- fluidPage(
  br(),
  selectInput(
    inputId = "some_id", 
    label = "Please choose A or B (get help)",
    choices = c("choice A", "choice B"),
    selected = "choice A",
    selectize = F
  ),
  actionLink(inputId = "action_link", label = "get help")
) # fluidPage

server <- function(input, output) {}

shinyApp(ui, server)

我猜解决方法是使用label = HTML(...),但是我不知道如何用纯html重写动作链接。

【问题讨论】:

    标签: r shiny


    【解决方案1】:
      selectInput(
        inputId = "some_id", 
        label = HTML("Please choose A or B", 
                     as.character(actionLink(inputId = 'action_link', label = 'get help'))),
        choices = c("choice A", "choice B"),
        selected = "choice A",
        selectize = F
      )
    

    【讨论】:

    • 在使用updateSelectInput 时你会如何做到这一点,我尝试使用相同的HTML 块,但它只打印HTML 代码而不是预期的actionLink
    【解决方案2】:

    您也可以使用tags,例如ap

    library(shiny)
    
    ui <- fluidPage(
      br(),
      selectInput(
        inputId = "some_id", 
        label = p("Please choose A or B ",a("get help", href = "https://www.google.com/", target = "_blank")),
        choices = c("choice A", "choice B"),
        selected = "choice A",
        selectize = F
      )
    ) # fluidPage
    
    server <- function(input, output) {}
    
    shinyApp(ui, server)
    

    【讨论】:

    • 这种方法对我来说是新的。
    猜你喜欢
    • 2014-08-02
    • 1970-01-01
    • 2014-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-19
    • 2015-06-25
    相关资源
    最近更新 更多