Ember-cli:预期分配或函数调用

时间:2014-12-11 08:19:26

标签: ember.js ember-cli

每次ember server项目ember-cli时,我都会收到以下错误:

router.js: line 12, col 45, Expected an assignment or function call and instead saw an expression
router.js: line 16, col 48, Expected an assignment or function call and instead saw an expression
router.js: line 20, col 41, Expected an assignment or function call and instead saw an expression
router.js: line 23, col 25, Expected an assignment or function call and instead saw an expression

我已经越过我的router.js文件而无法找到问题:

import Ember from 'ember';
import config from './config/environment';

var Router = Ember.Router.extend({
  location: config.locationType
});

Router.map(function() {
    this.resource('dashboard',{path:'/'}),
    this.resource('items',{path:'/items'},function(){
        this.route('new'),
        this.route('edit',{path:'/:item_id'});
    }),
    this.resource('abilities',function() {
        this.route('new'),
        this.route('edit',{path:'/:ability_id'});
    }),
    this.resource('ships',function(){
       this.route('new'),
       this.route('edit',{path:'/:slug'});
    });
});

export default Router;

我认为路线上的动态段可能是问题,但是即使将它们更改为资源,错误仍然会出现。我确实有;在每一行的末尾而不是逗号,所以我尝试切换它,但这也没有解决它。任何关于我做错的建议都会受到赞赏。谢谢!

1 个答案:

答案 0 :(得分:1)

您需要在this.resourcethis.route条目之后使用分号,而不是逗号。这可能实际上不会影响程序行为,但它会使js [lh] int不满意。使用分号时报告的错误是什么?