请在反应值出现时(单击操作按钮时)重复显示微调器
library(shinycssloaders)
ui <- fluidPage(
titlePanel("Hello Shiny!"),
fluidRow(
column(width = 2, actionButton("actButton", "Click")),
column(width = 6, withSpinner(uiOutput("htmlExample")))
)
)
library(shiny)
library(shinycssloaders)
server<-function(input, output)
{
getRandomNumber <- function() {
Sys.sleep(1)
randamNumber <- runif(n = 1, min = 1e-12, max = .9999999999)
return(HTML(paste0("<h1>Hai Render Html ................",
randamNumber, "<h1>")))
}
observeEvent(input$actButton,{
if (input$actButton == 0)
return(0)
isolate({
output$htmlExample <- renderUI({
getRandomNumber()
})
})
})
}
答案 0 :(得分:0)
如何使用busyIndicator
来代替包shinysky
。
以下是一个示例代码:
library(shinysky)
library(shiny)
ui <- fluidPage(
titlePanel("Hello Shiny!"),
fluidRow(
column(width = 2, actionButton("actButton", "Click")),
busyIndicator(text = 'Rendering HTML....'),
column(width = 6, uiOutput("htmlExample"))
)
)
server<-function(input, output)
{
getRandomNumber <- function() {
Sys.sleep(2)
randamNumber <- runif(n = 1, min = 1e-12, max = .9999999999)
return(HTML(paste0("<h1>Hi Render Html ................",
randamNumber, "<h1>")))
}
observeEvent(input$actButton,{
if (input$actButton == 0)
return(0)
isolate({
output$htmlExample <- renderUI({
getRandomNumber()
})
})
})
}
shinyApp(ui, server)
希望它有所帮助!