1

次のエラー メッセージが表示されます。

**Uncaught TypeError: Cannot read property 'find' of undefined (13:24:29:797 | error, javascript)** 
at  (public_html/js/libs/ember-data-latest.js:3771:17)
at App.PostsRoute.Ember.Route.extend.model (public_html/js/app.js:16:25)
at superWrapper (public_html/js/libs/ember-1.0.0-rc.3.js:1044:16)
at Ember.Route.Ember.Object.extend.deserialize (public_html/js/libs/ember-1.0.0-rc.3.js:24232:22)
at Router._paramsForHandler (public_html/js/libs/ember-1.0.0-rc.3.js:23204:34)
at doTransition (public_html/js/libs/ember-1.0.0-rc.3.js:23348:27)
at Router.transitionTo (public_html/js/libs/ember-1.0.0-rc.3.js:23105:9)
at doTransition (public_html/js/libs/ember-1.0.0-rc.3.js:23979:25)
at Ember.Router.Ember.Object.extend.transitionTo (public_html/js/libs/ember-1.0.0-rc.3.js:23842:5)
at Ember.LinkView.Ember.View.extend.click (public_html/js/libs/ember-1.0.0-rc.3.js:24899:29)
at Ember.CoreView.Ember.Object.extend.trigger (public_html/js/libs/ember-1.0.0-rc.3.js:14355:21)
at superWrapper (public_html/js/libs/ember-1.0.0-rc.3.js:1044:16)
at Ember.merge.handleEvent (public_html/js/libs/ember-1.0.0-rc.3.js:16907:19)
at Ember.View.Ember.CoreView.extend.handleEvent (public_html/js/libs/ember-1.0.0-rc.3.js:16393:30)
at  (public_html/js/libs/ember-1.0.0-rc.3.js:14113:19)
at  (public_html/js/libs/ember-1.0.0-rc.3.js:4504:19)
at Ember.handleErrors (public_html/js/libs/ember-1.0.0-rc.3.js:411:17)
at invoke (public_html/js/libs/ember-1.0.0-rc.3.js:4502:16)
at tryable (public_html/js/libs/ember-1.0.0-rc.3.js:4687:14)
at Ember.tryFinally (public_html/js/libs/ember-1.0.0-rc.3.js:1199:24)
at Ember.run (public_html/js/libs/ember-1.0.0-rc.3.js:4691:16)
at Ember.EventDispatcher.Ember.Object.extend._bubbleEvent (public_html/js/libs/ember-1.0.0-rc.3.js:14112:18)
at  (public_html/js/libs/ember-1.0.0-rc.3.js:14058:25)
at Ember.handleErrors (public_html/js/libs/ember-1.0.0-rc.3.js:411:17)
at  (public_html/js/libs/ember-1.0.0-rc.3.js:14049:20)
at jQuery.event.dispatch (public_html/js/libs/jquery-1.9.1.js:3074:9)
at elemData.handle (public_html/js/libs/jquery-1.9.1.js:2750:28)

ここに私のapp.jsがあります:

App = Ember.Application.create();

App.store = DS.Store.extend({
    revision: 12,
    adapter: 'DS.FixtureAdapter'
});

App.Router.map(function () {
    this.resource('posts');
    this.resource('about');
});

App.PostsRoute = Ember.Route.extend({
    model: function () {
        return App.Post.find();
    }
});

App.Post = DS.Model.extend({
    id: DS.attr('string'),
    title: DS.attr('string'),
    author: DS.attr('string'),
    intro: DS.attr('string'),
    extended: DS.attr('string'),
    publishedAt: DS.attr('date')
});

App.Post.FIXTURES = [{
        id: '1',
        title: "this is test post",
        author: "Ali",
        publishedAt: new Date('12-24-2012'),
        intro: " A quick brown fox jumps over the lazy dogs. contains all the English alpabet",
        extended: "Their must be some extension for other languages :P :P :P",
    }, {
        id: '2',
        title: "TEST Daily POST",
        author: "Naveed",
        publishedAt: new Date('03-24-2013'),
        intro: " our aims is to touch the new horizons",
        extended: "TESTING , TESTING TESTING",
    }, {
        id: '3',
        title: "TEST2 Daily POST",
        author: "SAJJAD",
        publishedAt: new Date('01-15-2013'),
        intro: " Do Nothing, Get Every thing",
        extended: "We provide an easy way to connect and do business with your customer. We are here to make your life easy.",
    }
];
4

1 に答える 1

-1

ember-data-latest.js と ember-1.0.0-rc.3.js のバージョンの不一致により、同じ問題が発生しました。

解決策は、github の master ブランチを使用して ember.js / ember-data.js をゼロからビルドすることでした。

前提条件:

  • ruby 1.9、rubygems、bundler、git、javascript ランタイム エンジン (nodejs をインストール)

  • nodejs (または他の利用可能な JavaScript ランタイムはhttps://github.com/sstephenson/execjsを参照)

    nodejs ランタイム エンジンの場合 - Mac、Linux、または Windows の最新のバイナリ/ソースをhttp://nodejs.org/download/からダウンロードしてインストールします

( 1 ) ember.js をビルドする

git clone https://github.com/emberjs/ember.js ember

cd ember && bundle install

rake dist

(コンパイルしたら、「dist」ディレクトリを参照)

( 2 ) ember-data.js をビルドする

git clone https://github.com/emberjs/data.git

cd data && bundle install

rake dist

これが役立つことを願っています!

于 2013-05-07T08:35:52.283 に答える