Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 根据输入值的变化更新Shining UI的内容_Javascript_R_Shiny_Shiny Server - Fatal编程技术网

Javascript 根据输入值的变化更新Shining UI的内容

Javascript 根据输入值的变化更新Shining UI的内容,javascript,r,shiny,shiny-server,Javascript,R,Shiny,Shiny Server,我在ui.R中有以下内容 shinyUI(fluidPage( uiOutput("test"), mainPanel( tabsetPanel( tabPanel("Test",conditionalPanel("input.show==1",includeHTML("index.html"))) ) ) )) 在server.R中执行以下操作 ShinyServerFunction输入、输出{ output$test <- renderU

我在ui.R中有以下内容

shinyUI(fluidPage(
  uiOutput("test"),
    mainPanel(
      tabsetPanel(
  tabPanel("Test",conditionalPanel("input.show==1",includeHTML("index.html")))
  )
    )

))
在server.R中执行以下操作 ShinyServerFunction输入、输出{

  output$test <- renderUI({
      tmp <- readLines("www/termite.css")
      ifelse(grepl("#ccc",tmp[2]),tmp[2] <- gsub("#ccc","#FFF",tmp[2]),tmp[2] <- gsub("#FFF","#ccc",tmp[2]))
      write(tmp,"www/termite.css",sep = "\n")
      tmp <- readLines("index.html")
      tmp[8] <- gsub("This is a page","This is my page!",tmp[8])
      write(tmp,"index.html",sep = "\n")
      checkboxInput("show","change bg color",value=0)
  })

})
现在,服务器程序将在程序执行后更新termite.css文件。只有选中复选框时,才应在ui上加载index.html。但现在ui加载现有文件,不再更新。我尝试从服务器返回“includehtml”函数,但它没有加载所有外部文件。它正在加载external文件仅在从ui调用时使用。这里最初的颜色代码是FFF,所以当我选中复选框时,它应该加载背景颜色为ccc的页面,并且文本应该更改为这是我的页面!
提前感谢。

一个可复制的示例在这里最有帮助。一般来说,当你需要在Shining中创建动态内容时,你需要reactive。有一节是关于它的。@Paul.是的。当我需要动态内容时,我可以在server.R中使用reactive。但我的问题是在Shining中加载html和js。当我使用includehtml时,它会打开c在ui启动时连接,但不是在我选择输入之后。和uiOutput,htmlOutput没有加载从服务器返回所需的外部文件。这里有一个可复制的示例最有帮助。一般来说,当您需要在Shiny中创建动态的内容时,您需要反应。其中有一节。@Paul.Yes。当我想要动态的内容时我可以在server.R中使用reactive。但我的问题是在shiny中加载html和js。当我使用includehtml时,它会在ui启动时打开连接,但在我选择输入后不会打开。而uiOutput、htmlOutput不会加载从服务器返回的所需外部文件。
<!DOCTYPE html>
<html>
<head>
  <title>Hi there</title>
  <link href="termite.css" rel="stylesheet" type="text/css"/>
</head>
<body>
  This is a page
  a simple page
</body>
</html>
body {
 background-color: #FFF;
 cursor: default;
}