r语言 - 没有侧栏菜单的闪亮截图



你知道如果没有侧栏菜单,我可以截图所有闪亮的应用程序吗?

I've try "selector = #nameofmytabItem"但是没有成功。

下面是我的实际代码:
observeEvent(input$screenshot, {
screenshot(
selector = "#Radar_Moyennes2"
)

请检查以下内容:

library(shiny)
library(shinyjs)
library(shinydashboard)
library(shinyscreenshot)
ui <- dashboardPage(
dashboardHeader(title = "Simple tabs"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", icon = icon("th"), tabName = "widgets",
badgeLabel = "new", badgeColor = "green"),
actionButton("screenshot", "Take screenshot")
)
),
dashboardBody(
useShinyjs(),
tabItems(
tabItem(tabName = "dashboard",
h2("Dashboard tab content")
),
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$screenshot, {
shinyjs::addCssClass(selector = "body", class = "sidebar-collapse")
screenshot(
# selector = "body > div > div > section"
)
})
}
shinyApp(ui, server)

通过获取@ismirsehregal代码块,如果您只想截图dashboardBody功能,那么下面的代码应该可以工作。

library(shiny)
library(shinyjs)
library(shinydashboard)
library(shinyscreenshot)
ui <- dashboardPage(
dashboardHeader(title = "Simple tabs"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", icon = icon("th"), tabName = "widgets",
badgeLabel = "new", badgeColor = "green"),
actionButton("screenshot", "Take screenshot")
)
),
dashboardBody(
useShinyjs(),
tabItems(
tabItem(tabName = "dashboard",
h2("Dashboard tab content")
),
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$screenshot, {
shinyjs::addCssClass(selector = "body", class = "sidebar-collapse")
screenshot(
selector = "body > div > div > section"
)
})
}
shinyApp(ui, server)

相关内容

  • 没有找到相关文章

最新更新