我试图像这样将badgeLabel包括到menuSubItem中:
sidebarMenu(id="tabs",
menuItem("First Item",tabName="Item1"),
menuItem("Secon Item", tabName = "Item2", icon = icon("bell"),
menuSubItem("Sub Item1",tabName="subI1"),
menuSubItem("Sub Item2",tabName="subI2", badgeLabel = "beta", badgeColor = "blue")
)
)但我知道错误是:
menuSubItem中的错误(“子Item2",tabName = "subI2",badgeLabel = "beta",未使用的参数(badgeLabel = "beta",badgeColor =”蓝色“)
如果我把它放在menuItem中,它工作得很好,但我需要它在menuSubItem中。有什么建议吗?
发布于 2019-03-07 09:29:24
menuSubItem没有这个论点。因此,您需要编写自己的menuSubItem函数:
menuSubItem2 <- function (text, tabName = NULL, href = NULL, newtab = TRUE,
icon = shiny::icon("angle-double-right"),
selected = NULL, badgeLabel = NULL, badgeColor = "green") {
if (!is.null(href) && !is.null(tabName)) {
stop("Can't specify both href and tabName")
}
isTabItem <- FALSE
target <- NULL
if (!is.null(badgeLabel)) {
badgeTag <- tags$small(class = paste0("badge pull-right bg-",
badgeColor), badgeLabel)
}
else {
badgeTag <- NULL
}
if (!is.null(tabName)) {
shinydashboard:::validateTabName(tabName)
isTabItem <- TRUE
href <- paste0("#shiny-tab-", tabName)
}
else if (is.null(href)) {
href <- "#"
}
else {
if (newtab)
target <- "_blank"
}
tags$li(a(href = href, `data-toggle` = if (isTabItem)
"tab", `data-value` = if (!is.null(tabName))
tabName, `data-start-selected` = if (isTRUE(selected))
1
else NULL, target = target, icon, span(text), badgeTag))
}https://stackoverflow.com/questions/55039023
复制相似问题