【发布时间】:2020-07-19 23:09:48
【问题描述】:
我想根据其他 2 个 widgets 的值启用/禁用 Shiny widget,如下所示 -
library(shiny)
library(shinyWidgets)
shinyApp(
ui = fluidPage(
useShinyjs(),
prettyCheckbox(inputId = "Check1", label = "A"),
prettyCheckbox(inputId = "Check2", label = "B"),
uiOutput("Date_UI")
),
server = function(input, output) {
output$Date_UI =
renderUI(dateInput(inputId = "Date",
label = NULL,
width = "80%",
value = Sys.Date(),
min = Sys.Date() - 10,
max = Sys.Date() + 10)
)
observeEvent(c(
input$Check1,
input$Check2
),
{
if (input$Check1 || input$Check2) {
enable('Date')
} else {
disable('Date')
}
})
}
)
我希望这样,如果单击Check1 和Check2 中的任何一个,则将启用Date。因此,如果两者都未选中,则 Date 将被禁用。 GUI 应该以 Date 开头,禁用。
显然,上面的代码没有发生这种情况?你能帮忙指出哪里出了问题吗?
【问题讨论】: