r - 动态下载按钮
问题描述
嗨,我的 Shiny APP 中的下载按钮有问题。创建相应的 DF 后,我已经动态创建了按钮。现在我有下载不起作用的问题。如果我直接创建了按钮,下载就可以了。我对重置功能做了同样的事情,一切都在这里工作。有人可以告诉我我做错了什么吗?
这是 UI 中的按钮代码:
column(3, offset = 0, uiOutput("download.action", style = "text-align: center;"))
我的服务器代码如下所示:
output$download.action <- renderUI({
div(style = "display:inline-block;width:0%;", actionButton("downloadData", "Download", icon = icon("download"),
style = "
flex-grow: 1;
display: inline-block;
background-color:#999;
text-decoration: none;
font-weight: 300;
border: 1px dash transparent;
letter-spacing: 0.98pt;
border-color:#00245d;"))
})
output$downloadData <- downloadHandler(
filename = function() {
paste("test.xlsx")
},
content = function(file) {
write.xlsx(test3, file, row.names = FALSE)
}
)
})
当我直接创建按钮时,一切正常。
Shiny 没有给出错误信息。只有按钮不起作用。
解决方案
您应该替换actionButton
为downloadButton
.
output$download.action <- renderUI({
div(style = "display:inline-block;width:0%;", downloadButton("downloadData", "Download", icon = icon("download"),
style = "
flex-grow: 1;
display: inline-block;
background-color:#999;
text-decoration: none;
font-weight: 300;
border: 1px dash transparent;
letter-spacing: 0.98pt;
border-color:#00245d;"))
})
推荐阅读
- laravel - SVG 汉堡菜单:每次单击时如何更改其颜色?
- python - 根据最近 3 天的数据动态计算移动平均线 [PySpark]
- reactjs - React/Redux ReferenceError:在初始化之前无法访问“Action”
- php - 在 WooCommerce 单品页面显示总价,商品原价 * 最小数量
- css - 如何将 2 个按钮与一个具有 2 行的按钮对齐
- python - Django - 如何为不同的查询订购查询集?
- apache-flink - Apache Flink,每日轮班的事件时间窗口
- php - 如何在 Larave Blade 中显示有限的文本并删除 html 标签?
- javascript - 将多个列表合并在一起并为搜索栏提供建议
- javascript - 如何将 asp.net mvc 5 与最新的 Paypal checkout .net sdk v2 集成?