r - 如何将数据属性添加到 Shiny App 中的标签?
问题描述
在我的 Shiny App 中,我想为data
一些标签添加属性。例如,
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30,
data-title = "Simple slider",
data-intro = "This is a slider. Use it!")
HTML("<h2 data-title = 'Welcome to LAI287 basal insulin study'
data-intro = 'This is a quick tour of the functionalities in this dashboard.'>
LAI287 basal insulin study</h2>")
在这两种情况下,我都收到了很多错误。结果是添加data-title
并data-intro
让用户了解我的 Shiny App 中的功能。
解决方案
或许是这样的:
addAttributes <- function(slider){
slider$children[[2]] <- htmltools::tagAppendAttributes(
slider$children[[2]],
`data-title` = "Simple slider",
`data-intro` = "This is a slider. Use it!"
)
slider
}
addAttributes(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30
)
)
推荐阅读
- git - 为什么 GIT 不跟踪目录的新文件?
- angular - Angular 预建主题不适用于 Angular8 库
- python - 创建函数以查找 3 个值中的最大值的代码问题
- python - 删除字典中的空数据框
- python - Django 信号不适用于用户创建
- c++ - 如何使用 erase() 函数通过索引擦除向量?
- reactjs - 如何在 useState 钩子之后立即执行函数?
- java - Spring 应用程序看不到带有属性扩展名的文件(application.properties 除外)
- javascript - NodeJs:在mssql“完成”发射器中等待
- angular - Angular - 如何测试使用 viewProviders 的模板驱动表单组件?