我遇到此代码的问题
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 render中的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")))
})
为什么会发生这种情况请澄清一下! 提前谢谢!
答案 0 :(得分:0)
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。