Ember:构建错误意外的令牌

时间:2016-08-29 03:50:22

标签: javascript ember.js

我正在按照下面的教程尝试代码

controller index.js

import Ember from 'ember';

export default Ember.Controller.extend({
    emailAddress: '',

    isValid: Ember.computed.match('emailAddress', /^.+@.+\..+$/),
    isDisabled: Ember.computed.not('isValid')

    actions: {
        saveInvitation() {
            alert(`Saving of the following email address is in progress: ${this.get('emailAddress')}`);
            this.set('responseMessage', `Thank you! We've just saved your email address: ${this.get('emailAddress')}`);
            this.set('emailAddress', '');
        }
    }
});

index.hbs

<div class="jumbotron text-center">
    <h1>Coming Soon</h1>

    <br/><br/>

    <p>Don't miss our launch date, request an invitation now.</p>

    <div class="form-horizontal form-group form-group-lg row">
        <div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-1 col-md-5 col-md-offset-2">
            {{input type="email"  value=emailAddress class="form-control" placeholder="Please type your e-mail address." autofocus="autofocus"}}
        </div>
        <div class="col-xs-10 col-xs-offset-1 col-sm-offset-0 col-sm-4 col-md-3">
            <button class="btn btn-primary btn-lg btn-block" disabled={{isDisabled}} {{action 'saveInvitation'}}>Request invitation</button>
        </div>

    </div>
    {{#if responseMessage}}
    <div class="alert alert-success">{{responseMessage}}</div>
    {{/if}}

    <br/><br/>
</div>

我的期望是如果我点击按钮,调用saveInvitation操作并显示一个警告框,设置一个responseMessage属性,最后删除emailAddress的内容。

然而,我收到了这样的错误

Build error

library-app/controllers/index.js (in /Users/Cy/Desktop/ember/library-app/tmp/babel-input_base_path-oMvwkQCG.tmp/0)

The Broccoli Plugin: [Babel] failed with:
SyntaxError: library-app/controllers/index.js: Unexpected token (9:1)
    isDisabled: Ember.computed.not('isValid')

    actions: {
        saveInvitation() {
            alert(`Saving of the following email address is in progress: ${this.get('emailAddress')}`);
            this.set('responseMessage', `Thank you! We've just saved your email address: ${this.get('emailAddress')}`);

0 个答案:

没有答案