【问题标题】:Iframe not working correctly in my Shiny Appiframe 在我的 Shiny 应用程序中无法正常工作
【发布时间】:2021-07-29 20:56:43
【问题描述】:

我希望嵌入的网站显示在侧边栏菜单的右侧,但嵌入的网站显示在侧边栏菜单中。当用户按下细胞培养下的控制图时,嵌入的网站应该清楚地显示在右侧。这是我的问题图片]1

如何解决此错误? 这是我的代码:

    library(shiny)
library(shinydashboard)


ui <- 
    dashboardPage(skin="black",
                  dashboardHeader(title = "CPV Dashboard ", titleWidth = 450),
                  dashboardSidebar(
                      sidebarMenu(
                          menuItem("Tab 1", tabName = "tab 1", icon = icon("medicine"),
                                   menuItem("Cell Culture",
                                            menuItem("Control Chart",                     mainPanel(fluidRow(
                                                htmlOutput("frame")))))))


                      ),
                  
                  dashboardBody())

server = function(input, output, session){
    observe({ 
        
        test <<- paste0("https://google.com") #sample url
    })
    output$frame <- renderUI({
        input$Member
        my_test <- tags$iframe(src=test, height=800, width=800)
        print(my_test)
        my_test
    })
}
shinyApp(ui, server)

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    我认为您需要 dashboardPage 中的 dashBoardBody

    据我所知,您当前的代码没有这样做。

    library(shiny)
    library(shinydashboard)
    
    
    ui <-
      dashboardPage(
        skin = "black",
        dashboardHeader(title = "CPV Dashboard ", titleWidth = 450),
        dashboardSidebar(sidebarMenu(
          menuItem(
            "Tab 1",
            tabName = "tab 1",
            icon = icon("medicine"),
            menuItem("Cell Culture",
                     menuItem("Control Chart"))
          )
        )),
        
        dashboardBody(mainPanel(fluidRow(htmlOutput("frame"))
      ),
    
    ))
    
    server = function(input, output, session) {
      observe({
        test <<- paste0("https://google.com") #sample url
      })
      output$frame <- renderUI({
        input$Member
        my_test <- tags$iframe(src = test,
                               height = 800,
                               width = 800)
        print(my_test)
        my_test
      })
    }
    shinyApp(ui, server)
    

    【讨论】:

    • 谢谢@norie,这行得通!仅当用户单击“控制图”时才可以加载网站吗?现在网站会自动弹出,用户无需点击任何东西
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-15
    • 1970-01-01
    • 2022-01-28
    • 1970-01-01
    • 2022-07-22
    • 2021-10-31
    • 1970-01-01
    相关资源
    最近更新 更多