我正在尝试用react-rails
gem 制作表格。但我收到一个错误:
语法错误:[stdin]:24:11:意外。
通过试验我发现,这个问题在第一React.DOM.div
行(它在代码中标记),但我不明白,为什么会这样,我已经检查了一百次:)
组件/country_form.coffee:
@CountryForm = React.createClass
getInitialState: ->
name: ''
valid: ->
@state.name
handleChange: (e) ->
name = e.target.name
@setState "#{name}": e.target.value
handleSubmit: (e) ->
e.preventDefault()
$.post '', { country: @state }, (data) =>
@props.handleNewCountry data
@setState @getInitialState()
, 'JSON'
render: ->
React.DOM.form
onSubmit: @handleSubmit
React.DOM.div # Problem is here
className: 'form-group'
React.DOM.label
'Name'
React.DOM.input
type: 'text'
className: 'form-control'
name: 'name'
value: @state.name
onChange: @handleChange
React.DOM.div
className: 'form-group'
React.DOM.button
type: 'submit'
className: 'btn btn-primary'
disabled: !@valid()
'Save'
谢谢你的帮助!