【发布时间】:2015-10-23 11:34:17
【问题描述】:
我正在使用 GitHub 上的简单测试来测试 extendShinyJs:link。
我已经安装了 V8 包,但我得到了这个错误,即使是示例脚本: 错误:shinyjs:解析提供的 JavaScript 代码时出错。
我还尝试将 JavaScript 代码移动到 www 文件夹下的单独文件中。
当前会话的附加信息:
> sessionInfo()
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
知道如何运行extendShinyjs吗?
在 ui.R 中:
library(shiny)
library(shinyjs)
library(shinyAce)
#library(V8)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
shinyjs::useShinyjs(),
extendShinyjs(text = "myfunc.js"),
navbarPage("Tweets stuff",
tabPanel("Contact",
sidebarLayout(
sidebarPanel(
textInput("ctFrom", "From:", value=""),
textInput("ctSubject", "Subject:", value="Sugerencias BTT"),
actionButton("ctSend", "Send")
),
mainPanel(
aceEditor("ctMessage", value="")
)
)
))
)
)
myfunc.js (in www folder):
shinyjs.pageCol = function(params){
$('body').css('background', params);
};
server.R:
shinyServer(function(input, output, session) {
#Programming with Twitter API
observeEvent(input$ctSend, {
#I have more things here
js$pageCol (input$ctSend)
})
}
请问您是否认为需要查看更多代码。 我想清除“aceEditor”中的文字。
感谢您的快速帮助。
【问题讨论】:
-
作为健全性检查,您可以向我们展示代码吗?我刚刚安装了 shiny 和 v8 并运行了示例,但直到我故意在 JS 部分中添加了一个错字后才能重现该错误
-
您好,我是
shinyjs的作者,只有当您的javascript 确实无效时才会发生该错误。如果您可以发布一个完全可重现的错误示例代码,我可以尝试帮助调试 -
我还没试过运行你的代码,但是由于你使用的是单独的js文件,你需要做
extendShinyjs(script = "myfunc.js")。仅当您将 JS 代码作为字符串提供时,才使用text参数。 PS。如果您发布一个最小的示例,而不是包含 shinyAce 和其他 UI 组件的示例,调试起来会更容易
标签: javascript r shiny shinyjs