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"


基础教程推荐
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 动态更新多个选择框 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 我什么时候应该在导入时使用方括号 2022-01-01