5

我尝试在此处的链接之后实现页面刷新按钮。但是,当我尝试部署到时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

4

1 回答 1

24

为了完整起见,下面的代码是一个使用“刷新”按钮的 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)

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

于 2016-01-13T03:42:41.710 回答