R 菜单项“单击”未在仪表板中触发

R 菜单项“单击”未在仪表板中触发,r,shiny,shinydashboard,R,Shiny,Shinydashboard,我正在建造一个闪亮的仪表板。我已经构建了代码UI部分。现在我想添加应该动态显示在右侧的菜单项的内容。我已为选项卡项应用了observerevent。但它不能正常工作,如下所示: 代码: 库(闪亮) 图书馆(shinythemes) #用户界面客户端。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 ui试试这个: library(shiny) library(shinythemes) library(shinydashboard) #UI client................

我正在建造一个闪亮的仪表板。我已经构建了代码UI部分。现在我想添加应该动态显示在右侧的菜单项的内容。我已为选项卡项应用了observerevent。但它不能正常工作,如下所示:

代码:

库(闪亮)
图书馆(shinythemes)
#用户界面客户端。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
ui试试这个:

library(shiny)
library(shinythemes)
library(shinydashboard)

#UI client..............................

ui <- fluidPage(
  tags$style(HTML("
                  h4 {
                  color: white;
                  padding-top: 5px;
                  font-weight: bold;
                  }
                  .content-wrapper{
                  overflow:auto;
                  width:150%;
                  }

                  "
  )
  ),
  dashboardPage(

    dashboardHeader(title="OPTUM",
                    tags$li(h4("Welcome User!"),
                            class = "dropdown",
                            dropdownMenu(type = "messages",
                                         messageItem(
                                           from = "Logout",
                                           message = "Session Ends"
                                         ))

                    )),
    ## Sidebar content

    dashboardSidebar(
      sidebarMenu(id = "tabs",
                  menuItem("OverView", tabName = "Sitecontent", icon = icon("th")),
                  menuItem("Candidate Information", tabName = "CandidateInformation", icon = icon("th")),
                  menuItem("Assesment", tabName = "Assesment", icon = icon("th"),

                           menuItem('Affect',
                                    tabName = 'AffectTab',
                                    icon = icon('th'))
                  )
      )
    ),
    dashboardBody(
      tabItems(
        # OverView tab  content
        tabItem(tabName = "OverView",
                h2("OverView ")

        ),

        # Assesment tab content
        tabItem(tabName = "Assesment",
                h2("Assesment ")


        ),

        # Predictive Result tab content
        tabItem(tabName = "PredictAny",
                h2("PredictAny")

        ),

        # PreventiveResults tab content
        tabItem(tabName = "PreventiveResults",
                h2("PreventiveResults")
        ),
        tabItem(tabName = "AffectTab",
                h2("Assesment on Affect")
        )
      )
    )
  )
  )

server <- function(input, output,session) { 

  observeEvent(input$tabs, {  #Not triggering
    print(input$tabs)
    if(input$tabs=="AffectTab"){
      sendSweetAlert(
        session = session,
        title = "Done!",
        text = "Affect Triggered.",
        type = "success"
      )
    }
  })
}
shinyApp(ui, server)
库(闪亮)
图书馆(shinythemes)
图书馆(shinydashboard)
#用户界面客户端。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
用户界面
library(shiny)
library(shinythemes)
library(shinydashboard)

#UI client..............................

ui <- fluidPage(
  tags$style(HTML("
                  h4 {
                  color: white;
                  padding-top: 5px;
                  font-weight: bold;
                  }
                  .content-wrapper{
                  overflow:auto;
                  width:150%;
                  }

                  "
  )
  ),
  dashboardPage(

    dashboardHeader(title="OPTUM",
                    tags$li(h4("Welcome User!"),
                            class = "dropdown",
                            dropdownMenu(type = "messages",
                                         messageItem(
                                           from = "Logout",
                                           message = "Session Ends"
                                         ))

                    )),
    ## Sidebar content

    dashboardSidebar(
      sidebarMenu(id = "tabs",
                  menuItem("OverView", tabName = "Sitecontent", icon = icon("th")),
                  menuItem("Candidate Information", tabName = "CandidateInformation", icon = icon("th")),
                  menuItem("Assesment", tabName = "Assesment", icon = icon("th"),

                           menuItem('Affect',
                                    tabName = 'AffectTab',
                                    icon = icon('th'))
                  )
      )
    ),
    dashboardBody(
      tabItems(
        # OverView tab  content
        tabItem(tabName = "OverView",
                h2("OverView ")

        ),

        # Assesment tab content
        tabItem(tabName = "Assesment",
                h2("Assesment ")


        ),

        # Predictive Result tab content
        tabItem(tabName = "PredictAny",
                h2("PredictAny")

        ),

        # PreventiveResults tab content
        tabItem(tabName = "PreventiveResults",
                h2("PreventiveResults")
        ),
        tabItem(tabName = "AffectTab",
                h2("Assesment on Affect")
        )
      )
    )
  )
  )

server <- function(input, output,session) { 

  observeEvent(input$tabs, {  #Not triggering
    print(input$tabs)
    if(input$tabs=="AffectTab"){
      sendSweetAlert(
        session = session,
        title = "Done!",
        text = "Affect Triggered.",
        type = "success"
      )
    }
  })
}
shinyApp(ui, server)