首页 > 解决方案 > 为什么在 Shiny 中列不跨页面分布?

问题描述

我认为整行是 12,所以 4 个 3 宽的列应该填满整个页面,但事实并非如此。图书馆(闪亮)

fluidPage(

    mainPanel(

      fluidRow(
        column(3,
               textInput("user_id", "User ID", width = NULL)
        ),

        column(3,
               textInput("name", "Organization name",value = "",width = NULL)
        ),
        column(3,

               textInput("address", "Address",value = "",width = NULL)
        ),
      column (3,
              textInput("zip", "Zip Code",value = "",width = NULL)
      )

      ) #row

    ) #panel

  ) #page

标签: rshiny

解决方案


默认情况下mainPanelwidth8 个。查看文档时可以看到:

?shiny::mainPanel

主面板(...,宽度 = 8)

width = 12因此,您必须在mainPanel通话中明确说明。


fluidPage(

    mainPanel(

      fluidRow(
        column(3,
               textInput("user_id", "User ID", width = NULL)
        ),

        column(3,
               textInput("name", "Organization name",value = "",width = NULL)
        ),
        column(3,

               textInput("address", "Address",value = "",width = NULL)
        ),
      column (3,
              textInput("zip", "Zip Code",value = "",width = NULL)
      )

      ) #row

    , width = 12) #panel

  ) #page

..应该做的伎俩。


推荐阅读