moduleServer而不是callModule.moduleServer(与callModule)不同。moduleServer,以便我可以正确引用父会话,以便updateTabsetPanel在动态输出中正常工作renderUI。这篇文章演示了如何使用callModule将父会话传递到模块中,以便updateTabsetPanel可以引用父会话并相应地更新它。我在这里使用这种方法创建了一个最小的示例。有两个tabPanels,我们试图通过actionLink第一个中的 an 导航到第二个。该first_server模块是用 调用的callModule,我们可以将父会话参数作为附加参数传递,从而允许我们在 的updateTabsetPanel调用中引用它first_server。单击actionLinkthen 会将我们带到第二个模块 UI,如预期的那样:
library(shiny)
first_ui <- function(id) {
ns <- NS(id)
uiOutput(ns("goto_second_link_ui"))
}
second_ui <- function(id) {
ns <- NS(id)
p("It worked!")
}
first_server <- function(input, output, session, parent) {
output$goto_second_link_ui <- renderUI({
actionLink(session$ns("goto_second"), label …Run Code Online (Sandbox Code Playgroud)