是否可以使用bs4Dash R package?
选择启动时的默认标签在使用闪亮仪表板时,我使用updateTabSetPanel在开始时设置了默认标签。
下面是可复制的示例,我希望名为“ start”的选项卡成为启动时选择的选项卡。
library(shiny)
library(bs4Dash)
shiny::shinyApp(
ui = bs4DashPage(
navbar = bs4DashNavbar(),
sidebar = bs4DashSidebar(
skin = "light",
bs4SidebarMenu(
bs4SidebarHeader("Main content"),
bs4SidebarMenuItem(
"Classic theme",
tabName = "classic",
icon = "desktop"
),
bs4SidebarMenuItem(
"Start with me",
tabName = "start", # <---- start with me!
icon = "map"
)
)
),
controlbar = bs4DashControlbar(
skin = "light"
),
footer = bs4DashFooter(),
title = "Classic theme",
body = bs4DashBody(
bs4TabItems(
bs4TabItem(
tabName = "classic",
fluidRow(
bs4Box(
height = "600px",
title = "Box 1"
),
bs4Box(
height = "600px",
title = "Box 2"
)
)
)
)
)
),
server = function(input, output) {}
)
答案 0 :(得分:1)
在Shiny会话初始化后,使用JavaScript手动选择选项卡:
tags$head(tags$script('
$(document).on("shiny:sessioninitialized", function(event) {
$(\'a[data-value="start"]\').tab("show");
});
')),
您可以在bs4DashBody
中加入此代码段。