首页 > 解决方案 > 如何将小程序插入闪亮的 R

问题描述

我想包括使用闪亮的可视化分子结构的小程序(我是 html 和闪亮的初学者),我有两个问题。

首先,当我包含 html 文件时,它会生成错误“连接到服务器时出错:https://chemapps.stolaf ...”

代码:

ui = shinyUI(fluidPage(
  includeHTML("applet.html"),
  mainPanel()
))

其中 applet.html 是:

<html>
<body>
Applet
<script type="text/javascript" 
src="http://chemapps.stolaf.edu/jmol/jmol.php?model=acetone&inline">
</script>
</body>
</html>

但是,如果我在运行代码后按“在浏览器中打开”,它工作正常。它可以在没有在浏览器中打开的情况下闪亮地工作吗?

其次,更重要的是我需要从服务器加载小程序:

#  ----- ui.R -----
ui = shinyUI(fluidPage(
  mainPanel(
    htmlOutput("inc")
  )
))

#  ----- server.R -----
server = shinyServer(function(input, output) {
  getPage<-function() {
    return(includeHTML("applet.html"))
  }
  output$inc<-renderUI({getPage()})
})

但是,小程序不起作用,尽管似乎也正确加载了 html 文件,因为出现了“小程序”文本。

我将不胜感激任何帮助

标签: javascripthtmlrshiny

解决方案


推荐阅读