在 rmarkdown 中包含对 jquery 的调用会导致包出现问题吗?
Does including a call to jquery in rmarkdown cause issues with packages?
我正在尝试将 DT::datatable
添加到我使用 rmarkdown
创建的 HTML 文档中,但我遇到了其他人似乎也遇到过的问题( here and here).
这是我在文件开头的 yaml:
---
title: ''
output:
html_document:
theme: NULL
css: main.css
includes:
in_header: js.txt
---
这里是js.txt的内容:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="main.js"></script>
我的 yaml 或 js.txt 文件中是否有什么东西导致 DT::datatable
无法呈现?
答案是肯定的,它可能会导致问题。我不知道它是否只是包含了 jquery 的版本,或者它是否通过 yaml 在我的 header 中包含了一个 javascript 文件。无论哪种方式,通过删除 yaml 的 includes
部分并将我对 javascript main.js
的调用移动到 rmarkdown
文档的 body,我能够解决问题。 yaml 现在如下所示:
title: ''
output:
html_document:
theme: NULL
css: main.css
并且 <script src="main.js"></script>
现在只驻留在我的 .Rmd 文件中。希望这对以后的人有所帮助。
我正在尝试将 DT::datatable
添加到我使用 rmarkdown
创建的 HTML 文档中,但我遇到了其他人似乎也遇到过的问题( here and here).
这是我在文件开头的 yaml:
---
title: ''
output:
html_document:
theme: NULL
css: main.css
includes:
in_header: js.txt
---
这里是js.txt的内容:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="main.js"></script>
我的 yaml 或 js.txt 文件中是否有什么东西导致 DT::datatable
无法呈现?
答案是肯定的,它可能会导致问题。我不知道它是否只是包含了 jquery 的版本,或者它是否通过 yaml 在我的 header 中包含了一个 javascript 文件。无论哪种方式,通过删除 yaml 的 includes
部分并将我对 javascript main.js
的调用移动到 rmarkdown
文档的 body,我能够解决问题。 yaml 现在如下所示:
title: ''
output:
html_document:
theme: NULL
css: main.css
并且 <script src="main.js"></script>
现在只驻留在我的 .Rmd 文件中。希望这对以后的人有所帮助。