html - 在 R 中返回 renderUi 的完整 HTML 内容
问题描述
是否可以获取页面的完整 HTML 文本,该页面生成为闪亮的 renderUi 对象?我需要内容来使用 ajax 生成屏幕截图。
示例 1 按预期工作:页面直接在 ui 中生成。生成的 ui 对象包含完整的 HTML 文本。它可以保存为 .html 文件并在浏览器中打开以显示页面。
ui <- fluidPage(
div(numericInput("invalue", label = "Input", 10)),
h4(div("Output")),
textOutput("outvalue")
)
server <- function(input, output, session) {
output$outvalue <- renderText(input$invalue * 10)
}
shinyApp(ui, server)
界面内容:
<div class="container-fluid">
<div>
<div class="form-group shiny-input-container">
<label for="invalue">Input</label>
<input id="invalue" type="number" class="form-control" value="10"/>
</div>
</div>
<h4>
<div>Output</div>
</h4>
<div id="outvalue" class="shiny-text-output"></div>
</div>
示例 2 无法正常工作:页面在服务器端使用 renderUI 生成并发送到 ui 函数,在该函数中通过 uiOutput 处理。该页面看起来与示例 1 中的完全相同,但生成的 ui 对象仅包含一行。如果将其保存为 .html 文件并在浏览器中打开,则不会显示任何内容。
ui <- uiOutput("page")
server <- function(input, output, session) {
output$outvalue <- renderText(input$invalue * 10)
output$page <- renderUI({
fluidPage(
div(numericInput("invalue", label = "Input", 10)),
h4(div("Output")),
textOutput("outvalue")
)
})
}
shinyApp(ui, server)
界面内容:
<div id="page" class="shiny-html-output"></div>
所以问题是:是否有可能从示例 2 中获取完整的 HTML 内容?我需要它来从页面生成一个 ajax 屏幕截图,该页面是使用 renderUi 动态生成的。
解决方案
推荐阅读
- python - 当“无论用户是否登录时运行”打开时,无法使用 python 在任务调度程序上发送电子邮件
- json - FormatException:意外字符(在第 2 行,第 13 个字符)。Dart/Flutter json解码
- java - Java 递归范围变量
- r - read.table 忽略空格并转换为字符
- git - Git 接收后挂钩
- python - LSTM-CNN 对图像序列进行分类
- css - SassError:无效的 CSS 预期表达式(例如 1px,粗体)
- xamarin - 如何使用 Xamarin MessagingCenter 让一页订阅来自多个不同页面的消息?
- python - 使用 docker-compose 'command:' 运行时,Supervisord 退出 Docker 容器,但从 bash 运行时不会退出
- xcode - IOS - 有没有办法在 xcode 中使用 NFC 权利进行调试而无需支付开发人员帐户费用(不分发)