如何更新闪亮的TextInput框?

时间:2019-01-29 10:03:31

标签: r

我正在尝试将result1 textInput小部件更新为以下内容,但是当我在server()中编写updateTextInput函数时,它总是闪烁。有人可以告诉我吗?我很忙我的工作。

#Define
ui = fluidPage(
  #--------------
  tabPanel("tab2",
           div(style="display: inline-block;vertical-align:middle; width: 130px;",
               textInput("result1","result1","0")),
           div(style="display: inline-block;vertical-align:moddle; width: 10px;",
               p("")),
           div(style="display: inline-block;vertical-align:moddle; width: 30px;",
               h4(p("="))),
           div(style="display: inline-block;vertical-align:middle; width: 100px;",
               textInput("var1","length","var1")),#length
           div(style="display: inline-block;vertical-align:moddle; width: 10px;",
               p("")),
           div(style="display: inline-block;vertical-align:moddle; width: 20px;",
               h4(p("/"))),
           div(style="display: inline-block;vertical-align:middle; width: 150px;",
               textInput("var2","c_sec","var2")),
           div(style="display: inline-block;vertical-align:moddle; width: 10px;",
               p("")),
           div(style="display: inline-block;vertical-align:moddle; width: 20px;",
               h4(p("x"))),
           div(style="display: inline-block;vertical-align:middle; width: 100px;",
               selectInput("selc1","resis",choices = list("copper" = 0.0174, "Alum" = 0.0282)))#電阻率
           ),
  #-------------
  tabPanel("tab9",
           div(style="display: inline-block;vertical-align:middle; width: 130px;",
           actionButton("btn2", "calculate")
           )
  )
  #--

)
#--Define server here----------------------------------
server = function(input, output) {
     observe({
       x = (input$var1/input$var2)*as.numeric(input$selc1)
       updateTextInput("result1",value = paste(x))
     })

}
shinyApp(ui, server)

0 个答案:

没有答案