gpt4 book ai didi

r - R Shiny 的页面刷新按钮

转载 作者:行者123 更新时间:2023-12-03 15:08:17 74 4
gpt4 key购买 nike

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

74 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com