我正在尝试根据我正在运行的当前测试的状态(可能是“Live”或“Archived”)动态更改侧边栏图标。我已经尝试过以下方法将图标的值分配给无功输出,但我无法使其工作。
ui.R
menuItem("AB calculator ", tabName = "calculator", icon = icon("hand-o-right")),
menuItem("AB calculator ", tabName = "test1", icon = icon(uiOutput('iconTest')))
server.R
output$iconTest<-renderUI({
"th"
})
这是一个可重现的例子
library(shiny)
shinyApp(
ui = bootstrapPage(
dashboardHeader(
title=" dashboard",
titleWidth = 250
),
dashboardSidebar(
sidebarMenu(
menuItem("AB calculator ", tabName = "test1", icon = icon(uiOutput('iconTest')))
)
),
dashboardBody(
)
),
server = function(input, output) {
output$iconTest<-renderUI({
iconTest<-"th"
})
}
)
由于
答案 0 :(得分:0)
也许你可以呈现整个menuItem
?
rm(list = ls())
library(shiny)
library(shinydashboard)
shinyApp(
ui = bootstrapPage(
dashboardHeader(title=" dashboard"),
dashboardSidebar(sidebarMenu( uiOutput('iconTest'))),
dashboardBody()
),
server = function(input, output) {
output$iconTest <- renderUI({
menuItem("AB calculator ", tabName = "test1", icon = icon('th'))
})
}
)
shinyApp(ui = ui, server = server)