使用renderUI登录闪亮的仪表板
我对此代码有问题使用renderUI登录闪亮的仪表板,r,shiny,shinydashboard,R,Shiny,Shinydashboard,我对此代码有问题 output$body <- renderUI({ if(USER$Logged==TRUE) {uiOutput("test_UI")} if (USER$Logged == FALSE) { box(title = "Login",textInput("userName", "Username"), passwordInput("passwd", "Password"), br(), actionButton("Login", "Log
output$body <- renderUI({
if(USER$Logged==TRUE)
{uiOutput("test_UI")}
if (USER$Logged == FALSE) {
box(title = "Login",textInput("userName", "Username"),
passwordInput("passwd", "Password"),
br(),
actionButton("Login", "Log in"))
}})
output$test_UI <- renderUI ({
tabItems(
tabItem(tabName = "me","Hello"),
tabItem(tabName = "Req", uiOutput("emp1")),
tabItem(tabName = "Cand", uiOutput("emp2")),
tabItem(tabName = "Candcomp",uiOutput("emp3")))
})
如果我删除body Renderi中的两个if条件,则效果良好:
output$body <- renderUI({
uiOutput("test_UI")
}})
output$test_UI <- renderUI ({
tabItems(
tabItem(tabName = "me","Hello"),
tabItem(tabName = "Req", uiOutput("emp1")),
tabItem(tabName = "Cand", uiOutput("emp2")),
tabItem(tabName = "Candcomp",uiOutput("emp3")))
})
为什么会发生这种情况请澄清!
提前谢谢
output$body <- renderUI({
if(USER$Logged==TRUE)
{uiOutput("test_UI")}
else {
box(title = "Login",textInput("userName", "Username"),
passwordInput("passwd", "Password"),
br(),
actionButton("Login", "Log in"))
}})
output$test_UI <- renderUI ({
tabItems(
tabItem(tabName = "me","Hello"),
tabItem(tabName = "Req", uiOutput("emp1")),
tabItem(tabName = "Cand", uiOutput("emp2")),
tabItem(tabName = "Candcomp",uiOutput("emp3")))
} )
只需使用if和else就可以了。您尝试过使用conditionalPanel吗?没有。但是如果您知道如何让它在这里工作,那将非常有帮助!谢谢迈克尔·伯德的帮助!事实证明,条件面板帮助我解决了if-else问题。