R 使用操作按钮转到其他选项卡
我有以下闪亮的应用程序:R 使用操作按钮转到其他选项卡,r,shiny,R,Shiny,我有以下闪亮的应用程序: ui <- fluidPage( tabsetPanel( tabPanel("Tab 1", actionButton("switch_tab", "Go to the second tab") ), tabPanel("Tab 2", "there!"), tabPanel("Tab 3", "there!")) ) server <- function(input, output, session)
ui <- fluidPage(
tabsetPanel(
tabPanel("Tab 1",
actionButton("switch_tab", "Go to the second tab")
),
tabPanel("Tab 2", "there!"),
tabPanel("Tab 3", "there!"))
)
server <- function(input, output, session) {
observeEvent(input$switch_tab, {
updateTabsetPanel(session, "inTabset",
selected = "Tab 3")
})
}
shinyApp(ui = ui, server = server)
ui您需要向tabsetpanel添加id
library(shiny)
ui <- fluidPage(
tabsetPanel(
id="inTabset",
tabPanel("Tab 1",actionButton("switch_tab", "Go to the third tab")
),
tabPanel("Tab 2", "there!"),
tabPanel("Tab 3", "there!"))
)
server <- function(input, output, session) {
observeEvent(input$switch_tab, {
updateTabsetPanel(session, "inTabset",selected = "Tab 3")
})
}
shinyApp(ui = ui, server = server)
库(闪亮)
用户界面