我正在學習用軌從here反應錯誤。在下面的教程我canme到這個錯誤 ExecJS::RuntimeError in Records#index SyntaxError: [stdin]:41:13: cannot have an implicit value in an implicit object
爲什麼標籤空間導致咖啡腳本
然後從谷歌的一點點研究,我來了解錯誤是因爲標籤空間。
檢查該反應的js代碼:
@RecordForm = React.createClass
getInitialState: ->
title: ''
date: ''
amount: ''
render: ->
React.Dom.form
className: 'form-inline'
React.DOM.div
className: 'form-group'
React.DOM.input
type: 'text'
className: 'form-control'
placeholder: 'Date'
name: 'date'
value: @state.date
onChange: @handleChange
React.DOM.div
className: 'form-group'
React.DOM.input
type: 'text'
className: 'form-control'
placeholder: 'Title'
name: 'title'
value: @state.title
onChange: @handleChange
React.DOM.div
className: 'form-group'
React.DOM.input
type: 'number'
className: 'form-control'
placeholder: 'Amount'
name: 'amount'
value: @state.amount
onChange: @handleChange
React.DOM.button
type: 'submit'
className: 'btn btn-primary'
disabled: [email protected]id()
'Create record'
handleChange: (e) ->
name = e.target.name
@setState "#{ name }": e.target.value
valid: ->
@state.title && @state.date && @state.amount
handleSubmit: (e) ->
e.preventDefault()
$.post '', { record: @state }, (data) =>
@props.handleNewRecord data
@setState @getInitialState()
, 'JSON'
render: ->
React.DOM.form
className: 'form-inline'
onSubmit: @handleSubmit
刪除空格'Create record'
之前,從上面的腳本會解決這個問題。您可以通過此utility(link)
縮進定義了CoffeeScript中的結構,因此您必須非常小心且與之一致。 –