我想在我的闪亮应用程序中显示一个链接,该链接指向基于用户输入生成的URL。我不想显示网址的全文。我知道如果事先知道URL,可以使用a(href =“”,label =“”)函数,但在这种情况下,URL取决于用户的输入。以下不起作用:嵌入反应生成的URL闪亮
ui <- fluidPage(
titlePanel("Show map of a given state"),
sidebarLayout(
sidebarPanel(
textInput("state", label = "State", value = "CA", placeholder = "California or CA"),
actionButton("showU","Show map")
),
mainPanel(
conditionalPanel(
condition = "input.showU > 0",
htmlOutput("url"),
a(href=htmlOutput("url"),"Show in Google Map",target="_blank")
)
)
)
)
server <- function(input, output){
observeEvent(input$showU,{
output$url <-renderUI({paste("https://www.google.com/maps/place/", input$state, sep="")})
})
}
shinyApp(ui,server)
我希望我可以点击“在Google地图中显示”并定向到动态生成的网址。请帮助我,谢谢。
网址非常感谢你一个HTML按钮!这正是我需要的。 –
@YuZhang高兴我的回答有帮助,请接受它 – HubertL