【问题标题】:Add pickerInput in header of R Shiny fullPage.js在 R Shiny fullPage.js 的头部添加 pickerInput
【发布时间】:2023-02-13 19:04:51
【问题描述】:

我正在使用包 fullPage 构建一个 R Shiny 应用程序;我想在页眉中(=出现在所有页面上)pickerInput 允许用户选择语言。

任何人都可以帮助实现这一目标吗?

我能做的,只是把这个元素放在第一页上,但我想把它放在所有页面上,最好是在标题中,与“菜单”处于同一级别(在“”旁边First'' 和 ''Second'' 在下面的最小示例中)。

library(shiny)
library(fullPage)
ui <- fullPage(
  menu=c("First"="first",
         "Second" ="second"),
  fullSection(
    menu = "first",
    center = TRUE,
    pickerInput(
      inputId = "lang_select",
      label = "Language",
      choices = c("ENG", "FR"),
      options = list(
        style = "btn-primary")
    ),
  
    h1("Callbacks")
  ),
  fullSection(
    menu = "second",
    center = TRUE,
    h3("Slice"),
    verbatimTextOutput("slide")
  )
)

server <- function(input, output){
}
shinyApp(ui, server)

【问题讨论】:

    标签: javascript r shiny fullpage.js


    【解决方案1】:

    要让 pickerInput 元素出现在 Shiny 应用的所有页面上,您可以将它添加到 fullPage 布局的标题部分。这是实现此目的的一种方法:

    library(shiny)
    library(fullPage)
    
    ui <- fullPage(
      header = pickerInput(
        inputId = "lang_select",
        label = "Language",
        choices = c("ENG", "FR"),
        options = list(style = "btn-primary"),
        inline = TRUE
      ),
      menu = c("First" = "first", "Second" = "second"),
      fullSection(
        menu = "first",
        center = TRUE,
        h1("Callbacks")
      ),
      fullSection(
        menu = "second",
        center = TRUE,
        h3("Slice"),
        verbatimTextOutput("slide")
      )
    )
    
    server <- function(input, output) {}
    
    shinyApp(ui, server)
    
    

    通过将 inline 参数设置为 TRUEpickerInput 将出现在标题中的菜单项旁边,并将其添加到 fullPageheader 参数,它将出现在菜单项的所有页面上应用程序。

    【讨论】:

      猜你喜欢
      • 2018-11-09
      • 2019-08-18
      • 2020-05-02
      • 2019-02-12
      • 2020-06-21
      • 2020-08-20
      • 1970-01-01
      • 2019-12-26
      • 2020-11-25
      相关资源
      最近更新 更多