ExecJS :: ProgramError:SyntaxError:保留字“function” [英] ExecJS::ProgramError: SyntaxError: Reserved word "function"

查看:926
本文介绍了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)

但是这段代码导致一个错误,是保留字。因为第一行基本上是一个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”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆