r - 在 Shiny 的 UI 部分中的文本内添加了空格
问题描述
我注意到当我使用时会出现一个空格em()
,strong()
并且显然,textOutput()
当它们p()
位于 ui 的标签内时,或者即使它们是松散的文本。这是我的代码:
ui <- fluidPage(
p("This is ", strong("bold"), ", and this is ", em("italic"), "."),
br(),
"Again, this is ", strong("bold"), ", and this is ", em("italic"), "."
)
服务器上什么都没有。这个textOutput()
例子有点长,它没有显示任何新的东西,所以我把它省略了。
输出是这样的:
这是粗体,这是斜体。
同样,这是粗体,这是斜体。
如您所见,逗号和句点由空格分隔。这真的很烦人——毕竟,标点符号在“正确的”英语中没有这个,这是我想在我的 Shiny App 中保留的东西。
解决方案
你可以使用.noWS
参数。
library(shiny)
ui <- fluidPage(
p("This is ", strong("bold", .noWS = c("after")), ", and this is ", em("italic"), "."),
br(),
"Again, this is ", strong("bold", .noWS = c("after")), ", and this is ", em("italic"), "."
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
结果:
This is bold, and this is italic .
Again, this is bold, and this is italic .
推荐阅读
- r - 混淆矩阵错误:错误:`data`和`reference`应该是具有相同水平的因素
- python - 重建一个窗口
- javascript - 为什么我在快递应用程序中“无法获取”页面?
- python - 用 Python 查找维基百科页面的主图
- javascript - Html Drag and Drop - 将浮动拖动的项目定位到光标
- javascript - 有什么办法可以返回我的 json 对象
- c - 使用 NT 存储将 64 字节内存复制到一个完整的高速缓存行与 2 个连续的部分高速缓存行
- api - 有什么方法可以在 API 测试工具中接收 API 调用?
- akka - Akka 中的无类型 ActorSystem 是什么?
- robotframework - ${time} = 获取时间 time=NOW + 1h 2min 3s # 1h 2min 3s 添加到本地时间