我在一个闪亮的应用程序中有多个tabItem。当我注释掉第二个tabItem时,第一个tabItem中的内容可以正确显示,但是当我同时拥有两个tabItem时,我只能看到第二个选项卡的内容。
下面是UI的代码。
library(shiny)
library(shinydashboard)
library(plotly)
dashboardPage(
dashboardHeader(title = "Loyalty Monthly Scorecard", titleWidth = 300),
## Sidebar content
dashboardSidebar(sidebarMenu(
menuItem("ATC Topline",tabName = "atc_topline"),
menuItem("Guidelines & KPI", tabName = "guidelines")
)),
## Body content
dashboardBody(tabItems(
tabItem(tabName = "atc_topline",
fluidRow(
box(
title = "ATC Topline Plot",
width = 12,
solidHeader = TRUE,
status = "primary",
plotlyOutput("plot"),
collapsible = T
)
)),
# # Second tab content
tabItem(tabName = "guidelines",
fluidRow(
includeHTML("include.html")
))
))
)
答案 0 :(得分:0)
虽然没有给出足够的问题说明,但尝试复制相同的内容,但没有发现问题。
这是我的代码:
ui.R
library(shiny)
library(shinydashboard)
library(plotly)
dashboardPage(
dashboardHeader(title = "Loyalty Monthly Scorecard", titleWidth = 300),
## Sidebar content
dashboardSidebar(sidebarMenu(
menuItem("ATC Topline",tabName = "atc_topline"),
menuItem("Guidelines & KPI", tabName = "guidelines")
)),
## Body content
dashboardBody(tabItems(
tabItem(tabName = "atc_topline",
fluidRow(
box(
title = "ATC Topline Plot",
width = 12,
solidHeader = TRUE,
status = "primary",
plotlyOutput("plot"),
collapsible = T
)
)),
# # Second tab content
tabItem(tabName = "guidelines",
fluidRow(
includeHTML("test.html")
))
))
)
Server.R
shinyServer(function(input, output) {
output$plot<-renderPlotly({
ggplotly(
ggplot(data = mtcars, aes(x = disp, y = cyl)) +
geom_smooth(method = lm, formula = y ~ x) +
geom_point())
})
})
html文件是基本的html文件:
<html>
<head>
header
</head>
<body>
Body
</body>
</html>
请尝试。还请清除问题说明。