Rails 4 + ReactJS:“语法错误:在隐式对象中不能有隐式值" [英] Rails 4 + ReactJS: "SyntaxError: cannot have an implicit value in an implicit object"
问题描述
我正在关注 Fernando Villalobos 的
但是,当我访问 localhost:3000/records
时,我收到以下错误:
ExecJS::RuntimeError in Records#indexSyntaxError: [stdin]:7:10: 在隐式对象中不能有隐式值<title>费用</title><%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' =>真 %><%= javascript_include_tag '应用程序', 'data-turbolinks-track' =>真 %><%= csrf_meta_tags %></头><身体>
特别是,导致问题的行似乎是:
<%= javascript_include_tag 'application', 'data-turbolinks-track' =>真 %>
知道问题是什么以及如何使事情发挥作用吗?
试试下面的 coffescript 代替你当前的 coffescript(只需从 coffescript 中删除 React.DOM
):
@Records = React.createClass渲染:->div类名:'记录'h2类名:'标题''记录'
I am following Fernando Villalobos' React.js - A guide for Rails developers AirPair tutorial.
The goal here is to build a simple expense tracking app, using Rails and React JS.
In the Nesting Components: Listing Records section, the author recommends to create a app/views/records/index.html.erb
file as follows:
<%# app/views/records/index.html.erb %>
<%= react_component 'Records', { data: @records } %>
AND a javascripts/components/records.js.coffee
file as follows:
# app/assets/javascripts/components/records.js.coffee
@Records = React.createClass
render: ->
React.DOM.div
className: 'records'
React.DOM.h2
className: 'title'
'Records'
Then, when we visit localhost:3000/records
, we are supposed to see the following:
However, when I visit localhost:3000/records
, I get the following error:
ExecJS::RuntimeError in Records#index
SyntaxError: [stdin]:7:10: cannot have an implicit value in an implicit object
<title>Expenses</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
In particular, the line causing the issue seems to be:
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
Any idea of what the probelm is and how I can make things work?
Try the following coffescript instead of your current coffescript(Just removing React.DOM
from the coffescript):
@Records = React.createClass
render: ->
div
className: 'records'
h2
className: 'title'
'Records'
这篇关于Rails 4 + ReactJS:“语法错误:在隐式对象中不能有隐式值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!