admin管理员组文章数量:1122846
I'm working in RStudio and am instructing knitr to include a JavaScript code chunk:
```{js, echo=FALSE}
import { MyModule } from './js/mymodule.js';
[other code]
```.
However, the JS engine is throwing an import error because I need the opening <script>
tag to contain the attribute type="module"
. Is there a way I can have knitr automatically add this attribute for me instead of putting in by hand in the resulting HTML file?
I'm working in RStudio and am instructing knitr to include a JavaScript code chunk:
```{js, echo=FALSE}
import { MyModule } from './js/mymodule.js';
[other code]
```.
However, the JS engine is throwing an import error because I need the opening <script>
tag to contain the attribute type="module"
. Is there a way I can have knitr automatically add this attribute for me instead of putting in by hand in the resulting HTML file?
1 Answer
Reset to default 2I'd suggest that you write the <script>
tag directly, since it's not much extra typing effort, and raw HTML elements work fine in Markdown.
<script type="module">
import { MyModule } from './js/mymodule.js';
[other code]
</script>
本文标签: htmlIs there a way in knitr to add an attribute to a script tagStack Overflow
版权声明:本文标题:html - Is there a way in knitr to add an attribute to a script tag? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736307751a1933421.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论