开发者社区> 问答> 正文

无法在RShiny应用程序中隐藏/显示流畅的页面

我目前正在开发一个闪亮的应用程序,成功登录后,我需要隐藏登录页面并显示闪亮的仪表板。如果没有,应显示登录页面。

我遇到了几个站点,因此决定使用shinyjs软件包来显示和隐藏活动页面/仪表板页面。

使用的全局函数如下:

%AND% <- function (x, y) { if (!is.null(x) && !anyNA(x)) if (!is.null(y) && !anyNA(y)) return(y) return(NULL) }

passwordInputAddon <- function (inputId, label, value = "", placeholder = NULL, addon, width = NULL) { value <- shiny::restoreInput(id = inputId, default = value) htmltools::tags$div( class = "form-group shiny-input-container", label %AND% htmltools::tags$label(label, for = inputId), style = if (!is.null(width)) paste0("width: ", htmltools::validateCssUnit(width), ";"), htmltools::tags$div( style = "margin-bottom: 5px;", class="input-group", addon %AND% htmltools::tags$span(class="input-group-addon", addon), htmltools::tags$input( id = inputId, type = "password", class = "form-control", value = value, placeholder = placeholder ) ) ) } 使用的UI代码如下:

ui <- shinyUI(fluidPage( tags$div(id = "login_page_ui", shinyjs::useShinyjs(), tags$style(".container-fluid {margin-top: 13%}"), setBackgroundColor(color = "#2d3c44"), fluidRow( column(8, align = "center", offset = 2, textInputAddon("name", label = "", placeholder = "Username", addon = icon("user"),width = "25%"), tags$style(type="text/css", "#string { height: 50px; width: 50%; text-align:center; font-size: 30px; display: block;}") ) ), fluidRow( column(8, align = "center", offset = 2, passwordInputAddon("password", label = "", placeholder = "Password", addon = icon("key"),width = "25%"),
tags$style(type="text/css", "#string { height: 50px; width: 50%; text-align:center; font-size: 30px; display: block;}") ) ),

      fluidRow(
        column(12, div(style = "height:20px;background-color: #2d3c44;")
        )

      ),

      fluidRow(
        column(6, align = "center", offset = 3,
               actionButton("login",label = "Login", width = "35%", style = "color: #fff; background-color: #1bc3d7; border-color: #1bc3d7;")))

) ),

shinyjs::hidden( tags$div( id = "dashboard_page_ui", dashboardPage( dashboardHeader( title="Shiny Dashboard", tags$li( class="dropdown" ) ), dashboardSidebar( sidebarMenu( id = 'dashboard_menu', sidebarMenuOutput("menu")

    )
  ),
  dashboardBody(
    tabItems(
      tabItem(tabName="Item1"),
      tabItem(tabName="Item2"),
      tabItem(tabName="Item3")
    )

  )

)

) ) ) 使用的服务器代码如下:

server <- function(input, output,session){ observeEvent(input$login,{

if((input$name == "Nevedha") & (input$password == "welcome123")){

  shinyjs::show("dashboard_page_ui")
  shinyjs::hide("login_page_ui")

}

})

} 当我执行此代码时,我收到此错误消息

Error in shinyUI(fluidPage(tags$div(id = "login_page_ui", shinyjs::useShinyjs(), : unused argument (shinyjs::hidden ..... 我不知道确切的问题是什么。谁能帮我解决这个问题?

展开
收起
被纵养的懒猫 2019-10-09 17:00:58 525 0
0 条回答
写回答
取消 提交回答
问答地址:
问答排行榜
最热
最新

相关电子书

更多
基于浏览器的实时构建探索之路 立即下载
内容驱动游戏分发 立即下载
动态、高效,蚂蚁动态卡片的内核逻辑 立即下载