我希望有一个闪亮的网站,将URL中的动态选择保持为输出,这样您就可以复制和共享URL.我把这段代码作为例子:https: //gist.github.com/amackey/6841cf03e54d021175f0
并将其修改为我的案例,这是一个网页,navbarPage每个元素在栏中有一个和多个标签.
我想要的是将用户引导到第一级tabPanel中的右侧元素的URL,以及第二级tabPanel中的右侧选项卡.
这是,如果用户导航到"Delta Foxtrot"然后导航到"Hotel",然后将参数更改为
#beverage=Tea;milk=TRUE;sugarLumps=3;customer=mycustomer,我希望URL将用户发送到"Delta Foxtrot" - >"Hotel",而不是从第一个面板元素的第一个选项卡.
理想情况下,我想要一个有效的例子,因为到目前为止我尝试的一切都没有用.
有任何想法吗?

# ui.R
library(shiny)
hashProxy <- function(inputoutputID) {
div(id=inputoutputID,class=inputoutputID,tag("div",""));
}
# Define UI for shiny d3 chatter application
shinyUI(navbarPage('URLtests', id="page", collapsable=TRUE, inverse=FALSE,
tabPanel("Alfa Bravo",
tabsetPanel(
tabPanel("Charlie",
tags$p("Nothing to see here. Everything is in the 'Delta Foxtrot' 'Hotel' tab")
)
)
)
,tabPanel("Delta Foxtrot",
tabsetPanel(
tabPanel("Golf",
tags$p("Nothing to see here. Everything is in the 'Delta Foxtrot' 'Hotel' tab")
)
,tabPanel("Hotel",
tags$p("This widget is a demonstration …Run Code Online (Sandbox Code Playgroud) 我有像我的闪亮应用程序中的代码:
$(function() {
Shiny.onInputChange('initialHash', parseHashQuery());
});
function parseHashQuery() {
var result = {};
location.hash.replace(/^#/, '').split('&').filter(Boolean).forEach(function(part) {
var pair = part.split('=');
result[pair[0]] = pair[1];
});
return result;
}
Run Code Online (Sandbox Code Playgroud)
但我有错误:
common.js:59 Uncaught TypeError: Shiny.onInputChange is not a function
at HTMLDocument.<anonymous> (common.js:59)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at Function.ready (jquery.min.js:2)
at HTMLDocument.K (jquery.min.js:2)
Run Code Online (Sandbox Code Playgroud) 假设您有一个简单的shinydashboard包含使用创建的链接menuItem和使用创建的页面tabItems:
library(shiny)
library(shinydashboard)
skin <- Sys.getenv("DASHBOARD_SKIN")
skin <- tolower(skin)
skin <- "blue"
## ui.R ##
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", icon = icon("th"), tabName = "widgets",
badgeLabel = "new", badgeColor = "green")
)
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "dashboard",
h2("Dashboard tab content")
),
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
# Put them together into a dashboardPage
ui<-dashboardPage(
dashboardHeader(title = "Simple tabs"),
sidebar, …Run Code Online (Sandbox Code Playgroud)