首页 > 解决方案 > 如何禁用 bs4dash (2.0.0.9000) 的dashboardHeader?

问题描述

我正在尝试禁用仪表板的标题组件。下面的代码是我这样做的尝试,使用 arg disable=TRUE。但是,此代码失败,因为标题仍然显示。


library(shiny)
library(bs4Dash)
library(shinyWidgets)
library(shinyjs)

loginpage <- div(id = "loginpage", 
                 bs4Card(width = 8, collapsible = FALSE, headerBorder = FALSE,
                         textInput("userName", placeholder="Username", label = tagList(icon("user"), "Username")),
                         passwordInput("passwd", placeholder="Password", label = tagList(icon("unlock-alt"), "Password")),
                         br(),
                         div(
                           style = "text-align: center;",
                           actionButton("login", "SIGN IN", width = '100%', style = "color: white; background-color:#000000;"),
                           shinyjs::hidden(
                             div(id = "nomatch", tags$p("Oops! Incorrect username or password!",
                                                        style = "color: red; font-weight: 600; padding-top: 5px;font-size:16px;", 
                                                        class = "text-center"))),
                           br(),
                         ))
                 
)

ui <- dashboardPage(
  dashboardHeader(id = "header", disable = TRUE, compact = TRUE),
  dashboardSidebar(disable = TRUE),
  dashboardBody(
    useShinyjs(),
    fluidRow(align = "center",
             setBackgroundImage(
               src = "https://www.fillmurray.com/1920/1080", 
               shinydashboard = TRUE),
             
             column(width = 4, offset = 4, style = "margin: 0;position: absolute;
                        top: 50%;left: 50%;-ms-transform: translate(-50%, -50%);transform: translate(-50%, -50%);",
                    loginpage
             )
    )
    
  )
)

server = function(input, output, session) {
  
  
  shinyjs::hide(id = "header", anim = FALSE)
  
}



# Run the application
shinyApp(ui = ui, server = server)

我还研究了使用闪亮的闪亮 js() 方法- 如何禁用 dashboardHeader。然而,使用那个答案给了我一个错误:

错误:shinyjs:extendShinyjs:functions必须提供参数。

我尝试的用户界面(未能禁用仪表板标题)

标签: rshinyshinydashboardbs4dash

解决方案


推荐阅读