我有以下创建 Flexdashboard 的代码:
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
我想插入一些 HTML 和 javascript 代码。我试过这个
Column
-----------------------------------------------------------------------
### Block 1
```{r}
<p>"This is a paragraph"</p>
<script>
alert("This is an alert")
</script>
```
但这不起作用。请问您能帮我解答这个问题吗?谢谢。
您可以直接键入 HTML 代码,无需块。您还可以使用tags
块中“htmltools”包的功能(或闪亮的 UI 功能)。对于 JavaScript,请使用js
chunk.
---
title: "TEST"
output:
flexdashboard::flex_dashboard:
orientation: rows
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r packages, include=FALSE}
library(flexdashboard)
library(htmltools)
```
Page
====================================
Row
-----------------------------
### HTML and JavaScript
<button id="btn">Click me</button>
```{js, echo=FALSE}
$("#btn").on("click", function() {
alert("You clicked the button!")
})
```
### HTML using 'htmltools'
```{r, echo=FALSE}
tags$button("Another button")
```
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)