请查看下面的快照。我想在左侧框的搜索栏中输入任何网站的网址,网页可以在右侧框中实时显示。命令" searchInput"我使用的是一个有光泽的小部件,并没有实现这一点。请帮我解决这个问题。此外,我想在应用程序像任何站点名称一样运行时提供默认网页链接。请帮帮我。
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(title = "Web Page"),
dashboardSidebar(
width = 0
),
dashboardBody(
box(title = "Web Page Search", status = "primary",height = "155"
,solidHeader = T,
uiOutput("search_plot")),
box( title = "Web Page", status = "primary", height = "618",solidHeader = T,
uiOutput("wep_page"))))
server <- function(input, output)
{
output$search_plot <- renderUI({
searchInput(inputId = "Id009",
label = "Enter the address",
placeholder = "A placeholder",
btnSearch = icon("search"),
btnReset = icon("remove"),
width = "100%")
})
output$wep_page <- renderUI({
})
}
shinyApp(ui, server)
答案 0 :(得分:1)
你可以这样做:
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(title = "Web Page"),
dashboardSidebar(
width = 0
),
dashboardBody(
box(title = "Web Page Search", status = "primary",height = "155"
,solidHeader = T,
uiOutput("search_plot")),
box( title = "Web Page", status = "primary", height = "860px",solidHeader = T,
uiOutput("wep_page"))))
server <- function(input, output)
{
output$search_plot <- renderUI({
searchInput(inputId = "Id009",
label = "Enter the address",
btnSearch = icon("search"),
btnReset = icon("remove"),
value='https://',
width = "100%")
})
output$wep_page <- renderUI({
print(input$Id009)
tags$iframe(src=input$Id009,width='100%',height='800px')
})
}
shinyApp(ui, server)
请注意,这可能需要一些调整。即检查网址是以http://
还是https://
开头,可能还有一些错误处理,但这可能会帮助您找到正确的方向。此外,并非所有网站都可以在iframe中呈现,有关详细信息,请参阅here。