我正在尝试将一个相对复杂的闪亮应用程序(3-4 个模块,8 个 CSS/JS 文件)转换为一个具有一个外部函数的包,该函数为给定的输入构建一个应用程序的实例(build_myApp(dataset1, title, factors)
存储在build_myApp.R
目录R/
中,以及和各种帮助文件)myApp_server.R
。myApp_ui.R
我一直在关注这个例子,现在一切正常,除了样式消失了。在这里,有人似乎有类似的问题,但没有尝试“功能化”他们的应用程序。
以前,我将外部文件放在顶级www
文件夹中,并从顶级文件中调用它们,ui.R
如下所示:tags$link(rel = "stylesheet", type = "text/css", href = "sample1.css")
或tags$script(src="www/sample.js")
. 但是我目前无法访问它们中的任何一个,并且可能无法访问其他外部 css,尽管很难确定。
我尝试将www
标题留在顶层,将其放在inst/
顶层文件夹中,然后将其移动到其中R/
并每次重新启动 R 会话和重建包。为了完成主义者,在所有我尝试过的排列中:
sample1.css
./sample2.css
../sample3.css
www/sample4.css
./www/sample5.css
../www/sample6.css
/www/sample7.css
inst/www/sample8.css
/inst/www/sample9.css
./inst/www/sample10.css
../inst/www/sample11.css
inst/sample12.css
/inst/sample13.css
./inst/sample14.css
../inst/sample15.css
不幸的是,Mastering Shiny Chapter没有提到它,我在网上找不到任何其他参考资料。任何建议将不胜感激,谢谢!