Rmd Flexdashboard中的ShinyAlert

时间:2019-02-20 14:09:37

标签: r shiny flexdashboard

我正在尝试在Rmd flexdashboard中渲染弹出窗口。

这是我的代码:

---
title: "Test"
output: flexdashboard::flex_dashboard
runtime: shiny
---

```{r global, include= FALSE}
library(shinyalert)
```


```{r}
  useShinyalert(  )
  actionButton("helpBtn", "Help")
```


```{r}
  observeEvent(input$helpBtn, {
  shinyalert(title = "Help Me!", text = "Please contact your instructor")})

```

该按钮显示出来,但是单击时不显示弹出窗口。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,由于需要shinyalert,我不认为您可以使用useShinyAlert()来做到这一点-在Rmd文档中添加额外的依赖项似乎并没有得到很好的支持。

一种解决方法是使用sendSweetAlert包中的shinyWidgets

---
title: "Test"
output: flexdashboard::flex_dashboard
runtime: shiny
---

```{r global, include= FALSE}
library(shinyWidgets)
```


```{r}
  actionButton("helpBtn", "Help")
```


```{r}
  observeEvent(input$helpBtn, {
  sendSweetAlert(session, title = "Help Me!", text = "Please contact your instructor")})

```