链接到闪亮应用程序的选项卡或面板 [英] Linking to a tab or panel of a shiny app
问题描述
如何将给定的闪亮部分链接到位于其他选项卡/面板上的部分?
How do I manage to link from a given shiny part to parts that are located on other tabs/panels?
我在下面起草的解决方案适用于链接到选项卡/面板的明确情况(这就是我所要求的).
The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).
不过,我也有兴趣了解链接闪亮应用的各个部分的更通用方法.
我想从面板 A 链接到面板 B,但我不太确定在单击面板 A 中的操作链接时需要将什么指定为操作.
I'd like to link from panel A to panel B, but I'm not quite sure what I need to specify as an action when the action link in panel A is clicked.
值 #tab-4527-2
来自调查 ui
的 HTML 输出,但我只是看到每次重新启动应用程序时这些值都会发生变化.
The value #tab-4527-2
came from investigating the HTML output of ui
, but I just saw that those values change each time I restart the app.
library(shiny)
# UI ---------------------------------------------------------------------
ui <- fluidPage(
tabsetPanel(
tabPanel(
"A",
p(),
actionLink("link_to_tabpanel_b", "Link to panel B")
),
tabPanel(
"B",
h3("Some information"),
tags$li("Item 1"),
tags$li("Item 2")
)
)
)
# Server ------------------------------------------------------------------
server <- function(input, output, session) {
observeEvent(input$link_to_tabpanel_b, {
tags$a(href = "#tab-4527-2")
})
}
shinyApp(ui, server)
推荐答案
我们刚刚发布了一个路由库,这使得在 Shiny 中链接变得容易.简而言之,这就是它的样子.
We have just released a routing library, which makes linking in Shiny easy. Here's how it looks like in a nutshell.
make_router(
route("<your_app_url>/main", main_page_shiny_ui),
route("<your_app_url>/other", other_page_shiny_ui)
)
更多信息可在此博文一>.
这篇关于链接到闪亮应用程序的选项卡或面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!