0

shinythemes我在我构建的应用程序中非常广泛地使用该库。我试图利用包中的 absModalshinyBS注意到“淡入” div 从未消失,因为没有可点击的东西,所以我留下了一个无法使用的 Web 应用程序。

所有示例shinyBS::bsModal都可以正常工作(它们是无光泽主题)。如何在使用模式的同时继续使用主题?

示例应用程序:

library(shiny)
library(shinyBS)
library(shinythemes)

app = shinyApp(
  ui =
    navbarPage(title=NULL,
      id="navbar",
      theme = shinytheme("journal"),
      tabPanel("test",
        column(1),
        column(3,
          sliderInput("bins",
            "Number of bins:",
            min = 1,
            max = 50,
            value = 30),
          actionButton("tabBut", "View Table")
        ),
        column(7,
          plotOutput("distPlot"),
          bsModal("modalExample", "Data Table", "tabBut", size = "large",
            dataTableOutput("distTable"))
        )
      )
    ),
  server =
    function(input, output, session) {

      output$distPlot <- renderPlot({

        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)

        # draw the histogram with the specified number of bins
        hist(x, breaks = bins, col = 'darkgray', border = 'white')

      })

      output$distTable <- renderDataTable({

        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)

        # draw the histogram with the specified number of bins
        tab <- hist(x, breaks = bins, plot = FALSE)
        tab$breaks <- sapply(seq(length(tab$breaks) - 1), function(i) {
          paste0(signif(tab$breaks[i], 3), "-", signif(tab$breaks[i+1], 3))
        })
        tab <- as.data.frame(do.call(cbind, tab))
        colnames(tab) <- c("Bins", "Counts", "Density")
        return(tab[, 1:3])

      }, options = list(pageLength=10))

    }
)

runApp(app)
4

1 回答 1

0

我不知道是什么导致了冲突,但解决方法是直接指定主题的链接。替换theme = shinytheme("journal")theme = "http://bootswatch.com/journal/bootstrap.css"调整您正在使用的主题的名称。

于 2016-05-06T18:27:30.230 回答