在某些情况下,我需要重新使用我shiny 的应用程序中的一些子模块,但我需要根据需要显示或隐藏同一模块中的一些元素.
当元素被隐藏时,我仍然希望为其分配一个缺省值.因为如果我没有保留缺省值,则在服务器中将找不到此元素中的参数,这将导致一些错误.
我想把每件事都做到in the UI only.
这是我的演示代码.
有可能做到吗?
mod_plot_ui <- function(id, showUI = FALSE){
ns <- NS(id)
tagList(
column(width = inputWidth,
box(
width = 12,
inputId = "input_card",
title = strong("Input Parameters"),
status = "primary",
if (isTRUE(showUI)) {
div(
numericInput(inputId = ns("myValue"),
label = NULL,
min = 0,
max = 10,
value = NA,
step = 0.001
)
)
} else {
div(here I need to hide the numericInput element, but keep the default value as NA)
}
)
))}