【发布时间】:2022-01-16 10:10:03
【问题描述】:
我已经了解了如何创建一个可以隐藏然后显示闪亮输出的 actionButton。例如下面的代码,基于this link:
dat <- data.frame(a=1:10, b=rexp(10, 1/10), c=letters[sample(1:24, 10)])
shinyApp(
ui = fluidPage(
useShinyjs(),
actionButton("hide", "Toggle"),
p("Text above plot"),
plotOutput("plot"),
p("Text below plot")
),
server = function(input, output, session) {
output$plot <- renderPlot({
plot(b ~ a, data=dat)
})
observeEvent(input$hide, {
toggle("plot") # if you want to alternate between hiding and showing
})
},
options = list(height = 700)
)
情节开始显示,然后您可以单击“切换”按钮使其消失,然后再次出现。但是,我需要它开始隐藏,然后用户可以点击使其出现然后消失。
我怎样才能让它开始隐藏?谢谢!
【问题讨论】:
-
试试
hidden(plotOutput("plot")) -
服务器功能中的
hide("plot")也可以使用。