【发布时间】:2020-08-20 08:10:16
【问题描述】:
我正在尝试使用 R Shiny 将状态添加到 URL 中。该应用程序在首次使用时工作正常,并且保持 URL 正常,但是当我使用 URL 或只是刷新浏览器时,应用程序不显示应该显示的情节。
javascript 控制台说: “错误:util.addPathParams 没有实现转义”
它也会抛出这个错误: 未处理的承诺拒绝:TypeError:a.LegacyGlobal.LP_explicit_ignored 不是函数。 (在 'a.LegacyGlobal.LP_explicit_ignored(document,e)' 中,'a.LegacyGlobal.LP_explicit_ignored' 未定义)
它似乎不喜欢 url 中的文本。
我发现我可以通过在 rstudio 网站上的第 1 课中使用“你好闪亮”并添加书签代码来复制我所犯的任何错误。我用 cmets 标记了编辑的行。 https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/
以下是 shinyapps.io 上的代码: https://jackprior.shinyapps.io/shinypractice/
#attempt to add bookmarking to rstudio lesson 1 and replicate bug
#https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/
library(shiny)
plotmsg =function(txt){return(plot(1:5,main=txt))} #this is new
ui <-function(request){ fluidPage( #UI wrapped in a function
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
textInput("w","name",value="a plot title"), #this is new
bookmarkButton() # This is new
),
mainPanel(
plotOutput("distPlot"),
plotOutput("plot"), # This is new
)
)
)
}
server <- function(input, output) {
output$plot <- renderPlot(plotmsg(input$w)) #this is new
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
shinyApp(ui = ui, server = server, enableBookmarking = "url") #this has added parameter
【问题讨论】: