ExecJS::ProgramError: SyntaxError: Reserved word quot;functionquot;(ExecJS::ProgramError: SyntaxError: 保留字“function)
问题描述
在我们的 rails rfq.js.coffee 中,我们只有一个简单的 js 代码:
In our rails rfq.js.coffee, we only have a simple js code:
$(function() {
$('#need_report').change(function(){
if ($(this).val() == true) {
$('#report_language').hide();
} // end if
}); // end change()
}); // end ready(function)
但是,此代码会导致错误,指出第一行中的 function() 是保留字.由于第一行基本上是一个 jquery $(document).ready(function () {})
,我们不知道为什么会出现这个错误.有什么想法吗?非常感谢.
However this code causes an error saying that function() in first line is a reserved word. Since the first line is basically a jquery $(document).ready(function () {})
, we have no clue why this error shows up. Any thoughts about it? Thanks so much.
推荐答案
你不能在 Coffeescript 文件中使用标准的 JS.将文件重命名为 rfq.js
,或将其转换为 coffeescript:
You can't use standard JS like that in a Coffeescript file. Either rename the file to rfq.js
, or convert it to coffeescript:
$ ->
$('#need_report').change ->
if $(this).val()
$('#report_language').hide()
这篇关于ExecJS::ProgramError: SyntaxError: 保留字“function"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ExecJS::ProgramError: SyntaxError: 保留字“function"


- 从原点悬停时触发 translateY() 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01