bsModal可与FluidPage一起使用,但不能没有它

时间:2019-03-22 06:33:46

标签: r shiny shinybs

我发现 bsModal fluidPage 中可以正常使用,但并非没有。只需单击“查看表”按钮以查看区别。

带有 fluidPage 的版本:

library(shiny)
library(shinyBS)

shinyApp(
  ui =
    fluidPage(
      sidebarLayout(
        sidebarPanel(
          actionButton("tabBut", "View Table")
        ),

        mainPanel(
          bsModal("modalExample", "Data Table", "tabBut", size = "large",
                  "distTable")
        )
      )
    ),
  server =
    function(input, output, session) {}
)

没有 fluidPage 的版本,唯一的变化是 fluidPage 被tagList取代:

library(shiny)
library(shinyBS)

shinyApp(
  ui =
    tagList(
      sidebarLayout(
        sidebarPanel(
          actionButton("tabBut", "View Table")
        ),

        mainPanel(
          bsModal("modalExample", "Data Table", "tabBut", size = "large",
                  "distTable")
        )
      )
    ),
  server =
    function(input, output, session) {}
)

有没有一天可以帮助我解释 bsModal fluidPage 之间发生了什么?

1 个答案:

答案 0 :(得分:0)

因为fluidPage比简单的tagList还要多得多。

tagList只需接受它的参数并将其连接起来(期望每个参数都是某种HTML标记)。 fluidPage从字面上生成具有引导程序依赖项的整个HTML文档。

您的第一个示例是形象地“用地下室,平面图和阁楼盖房子”,其中sidebarLayout解释了地板的布局,而fluidPage是房子。删除fluidPage,您将尝试建造一间带有地下室,平面图和阁楼的房子,但没有地基,墙壁或屋顶。

相关问题