我尝试在链接之后实现页面刷新按钮 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/