我尝试在此处的链接后实现页面刷新按钮.但是当我尝试部署时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"))
Run Code Online (Sandbox Code Playgroud)
在server.R:
observeEvent(input$reset_button, {js$reset()})
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点没有shinyjs?
Dea*_*ali 17
为了完整,下面的代码是使用"刷新"按钮的工作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)
Run Code Online (Sandbox Code Playgroud)
编辑:从闪亮版本0.13.0开始,可以使用Shiny的session$reload()功能刷新页面