Iframe 在我的 Shiny App 中无法正常工作

Iframe not working correctly in my Shiny App

我希望嵌入式网站显示在侧边栏菜单的右侧,但嵌入式网站显示在侧边栏菜单中。当用户按下 Cell Culture 下的控制图时,嵌入式网站应清楚地显示在右侧。这是我的问题的图片 ]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)

我认为您需要 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)