gpt4 book ai didi

r - 在没有 shiny.css 的情况下使用 Shiny

转载 作者:行者123 更新时间:2023-12-05 03:03:26 27 4
gpt4 key购买 nike

我喜欢 Shiny 及其提供的所有功能,但我不喜欢 shiny.css。似乎无论我如何构建我的应用程序,它都包含 shiny.css 并且它与我在头部声明的其他 CSS 样式冲突。

我试过很多东西。在 fluidPage 中引用它们似乎并没有省略它。

在 header 中声明 CSS 链接不会忽略它。

ui <- fluidPage(theme="bootstrap.css")

tags$link(type="text/CSS", href="bootstrap.css", rel="stylesheet"),

这就是将 bootstrap.css(和其他文件)放在 www 目录中

每次我启动 Shiny 的应用程序时,我都会默认使用 Shiny 的:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="application/shiny-singletons"></script>
<script type="application/html- dependencies">json2[2014.02.04];jquery[1.12.4];shiny[1.1.0]</script>
<script src="shared/json2-min.js"></script>
<script src="shared/jquery.min.js"></script>
<link href="shared/shiny.css" rel="stylesheet" />
<script src="shared/shiny.min.js"></script>

我可以忍受其他一切,我只是不想包含 shiny.css。

我的实际结果不会有带有 shiny.css 的标签。

最佳答案

考虑使用 htmlTemplate() 函数为 UI 使用 HTML 模板。
这样您就可以准确控制包含哪些 CSS/JS 脚本,哪些不包含。
在此处查看完整文章:https://shiny.rstudio.com/articles/templates.html

这是一个不包含 shiny.css 的工作示例:

library(shiny)

shinyApp(
ui = htmlTemplate(
text_ = '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="application/shiny-singletons"></script>
<script type="application/html-dependencies">json2[2014.02.04];jquery[1.12.4];shiny[1.2.0]</script>
<script src="shared/json2-min.js"></script>
<script src="shared/jquery.min.js"></script>
<script src="shared/shiny.min.js"></script>
</head>
<body>
{{btn}}
{{txt}}
</body>
</html>',
btn = actionButton('a','a'),
txt = textInput('b', 'b', 'b')
),

server = function(input, output, session) {
observeEvent(input$a, updateTextInput(session, 'b', 'B', 'B'))
}
)

关于r - 在没有 shiny.css 的情况下使用 Shiny,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53990366/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com