0

是否可以在启动时扩展 bs4Dash 手风琴项目?据我所知,手风琴函数没有输入值,所以我猜你必须使用一些 javascript,但我的 javascript 知识不是很好。

这是一些示例代码,其中包含失败的 javascript 尝试:

library(shiny)
library(bs4Dash)

shiny::shinyApp(
  ui = bs4DashPage(
    navbar = bs4DashNavbar(),
    sidebar = bs4DashSidebar(),
    controlbar = bs4DashControlbar(),
    footer = bs4DashFooter(),
    title = "test",
    body = bs4DashBody(
      bs4Accordion(
        id = "accordion",
        bs4AccordionItem(
          id = "item1",
          title = "Item 1",
          status = "danger",
          "Some text here"
        ),
        bs4AccordionItem(
          id = "item2",
          title = "Item 2",
          status = "warning",
          "Some text here"
        )
      ),
      tags$head(tags$script('
        $(document).on("shiny:sessioninitialized", function(event) {
          document.querySelector("#header_item1 a").setAttribute("aria-expanded", "true");
        });
      '))
    )
  ),
  server = function(input, output) {}
)
4

0 回答 0