5

ES6 を使用して、 ember アプリ キットと ember データを使用して新しいプロジェクトを開始しようとしています。次のコードを使用してストアを作成できましたadapter.js

var ApplicationAdapter = DS.FixtureAdapter.extend();
export default ApplicationAdapter;

ただし、モデルの作成とアクセスに失敗しています。models/account.js私はこれを持っています

var Account = DS.Model.extend({
  name: DS.attr('string')
});

Account.FIXTURES = [
  {
    'id': 1,
    'name': 'Acc 1'
  }, {
    'id': 2,
    'name': 'Acc 2'
  }
]

export default Account;

そして私のroutes/accounts.js中にはこれがあります:

var AccountsRoute = Ember.Route.extend({
  model: function() {
    var store = this.get('store');
    return store.find('account');
  }
});
export default AccountsRoute;

この段階では、画面に表示された備品からアカウントのリストを取得しようとしています。ルートはうまく機能し、静的データ (インデックス ルートなど) を入力すると、すべて正常に動作します。ただし、上記のコードでは、問題が発生します

DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object (error on <Ember.Route:ember352>)
    at Object.triggerEvent (http://localhost:8000/vendor/ember/index.js:30519:13)
    at trigger (http://localhost:8000/vendor/ember/index.js:29641:16)
    at handleError (http://localhost:8000/vendor/ember/index.js:29903:9)
    at invokeCallback (http://localhost:8000/vendor/ember/index.js:8055:19)
    at null.<anonymous> (http://localhost:8000/vendor/ember/index.js:8109:11)
    at EventTarget.trigger (http://localhost:8000/vendor/ember/index.js:7878:22)
    at http://localhost:8000/vendor/ember/index.js:8180:17
    at Object.DeferredActionQueues.flush     (http://localhost:8000/vendor/ember/index.js:5459:24)
    at Object.Backburner.end (http://localhost:8000/vendor/ember/index.js:5545:27) index.js:394
Error while loading route: 
Object {readyState: 4, getResponseHeader: function, getAllResponseHeaders: function,   setRequestHeader: function, overrideMimeType: function…}
 index.js:394
Uncaught #<Object> index.js:30566

どこが間違っていますか?

4

3 に答える 3

2

本当の問題は、 adapters/adapter.jsで Fixture Adapter を定義したことだと思います。

電話したとき:

store.find('account');

モデルは正しく検出されましたが、正しいアダプターが検索されました。あなたはadapters/account.jsを持っていないので、アプリケーションのデフォルトを使用しました。これはRESTAdapterです。

例を機能させるには、ファイル名を変更するだけです。

于 2014-01-06T04:50:56.903 に答える
1

同じエラーが発生していました...

ただし、ApplicationAdapter をインポートし、それを使用してストアを定義することで、これを修正できました。

アプリ/アダプター/application.js:

var ApplicationAdapter = DS.FixtureAdapter.extend();

export default ApplicationAdapter;

アプリ/ストア/application.js:

import ApplicationAdapter from 'appkit/adapters/application';
var Store = DS.Store.extend({
    adapter: ApplicationAdapter
});

export default Store;

appkit からデフォルトのアプリケーション名をまだ変更していないことに注意してください。この名前またはパスを変更して、この機能を適切に機能させる必要がある場合があります。

于 2013-09-29T04:59:50.630 に答える