我有一个定制的闪亮输入(MyInput),它允许您包含一个图标。可以在updateMyInput函数中更新图标。
如果最初给出一个图标的话,每件事都很好。但是,如果初始图标为NULL,并且在updateMyInput中添加了一个图标,则由于没有添加依赖项,它无法工作。
我试图在JS中使用Shiny.renderDependencies,但没有成功。
首先,我必须像这样将依赖项添加到图标对象中,否则它不会传递给JS。
icon$htmldeps <- htmltools::htmlDependencies(icon)然后在JS里我做了
Shiny.renderDependencies(data.icon.htmldeps)它使用错误的href (未定义)添加样式表:
<link rel="stylesheet" type="text/css" href="undefined/css/v4-shims.min.css">
<link rel="stylesheet" type="text/css" href="undefined/css/all.min.css">添加依赖项的正确方法是什么?
发布于 2020-03-14 11:52:44
在myInput函数中显式地添加依赖项:
# With htmltools >= 0.3.5
iconInput <- function(inputId, icon) {
tags$div(
id = inputId,
icon,
htmltools::findDependencies(shiny::icon("home"))
)
}
# With htmltools < 0.3.5
iconInput <- function(inputId, icon) {
htmltools::attachDependencies(
x = tags$div(
id = inputId,
icon
),
value = htmltools::findDependencies(shiny::icon("home"))
)
}在服务器端,您可以尝试:
icon$htmldeps <- shiny::createWebDependency(
htmltools::resolveDependencies(
htmltools::findDependencies(
shiny::icon("home")
)
)[[1]]
)https://stackoverflow.com/questions/60682024
复制相似问题