r - R Shiny 的页面刷新按钮

标签 r shiny shinyjs

我尝试在链接之后实现页面刷新按钮 here .但是,当我尝试部署到 shinyapp.io 时,它失败并要求安装包 V8我已经完成了。该应用程序在机器上运行良好。我使用的代码是:

jsResetCode <- "shinyjs.reset = function() {history.go(0)}",

useShinyjs(), # Include shinyjs in the UI

extendShinyjs(text = jsResetCode), # Add the js code to the page   

p(actionButton("reset_button", "Reset Tool"))

server.R :
observeEvent(input$reset_button, {js$reset()}) 

没有 shinyjs 有没有办法做到这一点?

最佳答案

为了完整起见,下面的代码是使用“刷新”按钮的 Shiny 应用程序的最小示例

library(shiny)
library(shinyjs)

jscode <- "shinyjs.refresh = function() { history.go(0); }"

ui <- fluidPage(
  useShinyjs(),
  extendShinyjs(text = jscode),
  textInput("text", "Text"),
  actionButton("refresh", "Refresh app")
)

server <- function(input, output, session) {
  observeEvent(input$refresh, {
    js$refresh();
  })
}

shinyApp(ui = ui, server = server)

编辑:从 Shiny 0.13.0 版本开始,可以使用 Shiny 的 session$reload() 刷新页面功能

关于r - R Shiny 的页面刷新按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34142841/

相关文章:

r - 在 R 列表中查找名称的时间复杂度是多少?

r - R 中关系表的跨度矩阵

r - 更新 shiny 中 actionButton 的标签

r - 在 Shiny 的应用程序中插入dygraph时出现问题

r - 点击后更新textInput

R 包 pROC 总是报告 AUC > 0.5

r - 如何处理 'rpart' 中的连续变量和离散变量 - 使用 R 的决策树?

r - 在 Shiny 中的 conditionalPanel 中添加多个条件

javascript - 在 Chrome 中重新加载动画 GIF 时出现问题

r - 使用 renderUI 更新数据集而不是条件面板