【发布时间】:2018-05-29 06:14:08
【问题描述】:
我试图了解为什么我的进度条(使用 timer.js 创建)中有灰色背景。
我尝试将背景颜色、背景样式更改为无或#FFFFFF,但灰色背景仍然存在。
服务器.R
function(input, output, session) {
mylevels <- reactive({
Sys.sleep(100)
input$num_levels
})
output$out <- renderText({
return(paste0(mylevels()," is selected.."))
})
}
ui.R:
library("shinythemes")
fluidPage(theme = shinytheme("spacelab"),
navbarPage("Test", id = "allResults",
tabPanel(value ='inputParam', title = 'User Actions',
sidebarLayout(
sidebarPanel(
# Show Timer
conditionalPanel("updateBusy() || $('html').hasClass('shiny-busy')",
id='progressIndicator',
"Calculation in progress ....\n",
div(class='progress',includeHTML("timer.js"))
),
tags$head(tags$style(type="text/css",
'#progressIndicator {',
' position: fixed; bottom: 15px; right: 15px; width: 225px; height: 70px;',
' padding: 8px; border: 0.5px dotted #CCC; border-radius: 8px; ',
'}'
)),
numericInput("num_levels", label = "", value = 3)
),
mainPanel(
textOutput('out')
)
)
)
))
<script type="text/javascript">
var wasBusy = false;
var elapsedTimer = null;
var startTime = null;
function updateBusy() {
var isBusy = $('html').hasClass('shiny-busy');
if (isBusy && !wasBusy) {
startTime = new Date().getTime();
elapsedTimer = setInterval(function() {
var millisElapsed = new Date().getTime() - startTime;
$('.progress').text(Math.round(millisElapsed/1000) + ' seconds have elapsed');
}, 1000);
}
else if (!isBusy && wasBusy) {
clearInterval(elapsedTimer);
}
wasBusy = isBusy;
}
</script>
【问题讨论】:
-
一个工作的 jsfiddle 或 codepen 可以提供帮助。您包含的此代码由于缺少库等而有错误
-
我认为缺少的部分是 timer.js(这是最底部的 sn-p)
-
您在样式属性的末尾使用了
!important? -
我不明白。 !important 是什么意思?
-
background-color: #FFFFFF !important。如果我能看到现场经验可以帮助你更多
标签: javascript css r shiny shinythemes