根据Fomantic UI
-文档,以下脚本生成顶部附加的toast
:
$.toast({
position: 'top attached',
title: 'Watch out!',
message: `I am a top attached toast`
});
在R
Package 器shiny.semantic
中,showNotification
函数不遵守top attached
命令,但它通常遵守位置参数,如下面提供的最小工作示例(MWE)所示。
# library
library(shiny)
library(shiny.semantic)
# application
if (interactive()) {
shiny::shinyApp(
ui = semanticPage(
title = 'Title',
actionButton(
inputId = 'show',
label = 'Click me!'
),
actionButton(
inputId = 'bottom_left',
label = 'Bottom left!'
),
actionButton(
inputId = 'top_attached',
label = 'Top attached!'
)
),
server = function(input,output) {
observeEvent(
input$bottom_left,
{
showNotification(
ui = 'Where am I?',
type = 'default',
position = 'bottom left'
)
}
)
observeEvent(
input$top_attached,
{
showNotification(
ui = 'Where am I?',
type = 'default',
position = 'top attached'
)
}
)
observeEvent(
input$show,
{
toast(
title = 'See me!',
message = 'Where am I?',
toast_tags = tags$script(
"($.toast({position: 'top attached'}))"
)
)
}
)
}
)
}
如何使用基本R
和shiny.semantic
使showNotification
或toast
函数服从top attached
命令?
1条答案
按热度按时间icnyk63a1#
虽然没有文档记录,但
toast_tags
接受一个命名的向量或列表。所以你对toast()
的调用应该是:这在您的MWE中对我有效(
toast_tags = c(position = 'top attached')
也是如此)