簡體   English   中英

TypeError Ember.js

[英]TypeError Ember.js

因此,當我談到Ember時,我仍然是一個初學者。現在,我試圖從Ember-data中了解子類DS.Model。 因此由於某種原因,當我路由到帖子時,它會出現以下錯誤:

處理路線時出錯:未定義的帖子不是函數TypeError:未定義的不是函數

App = Ember.Application.create();


App.Store = DS.Store.extend({
    revision: 12,
    //where do we have to look for those records?
    adapter: 'DS.FixtureAdapter'

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

});


App.PostsRoute = Ember.Route.extend({
    //we're returning all the data that our application knows about
    model: function() {
        return App.Post.find();
    }

});

App.Post = DS.Model.extend({
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: "Rails is Omakase",
  author: "d2h" ,
  date: new Date('12-27-2012'),
  excerpt: "There are lots of à la carte software environments in this world. Places where in order to eat, you must first carefully look over the menu of options to order exactly what you want.",
  body: "I want this for my ORM, I want that for my template language, and let's finish it off with this routing library. Of course, you're going to have to know what you want, and you'll rarely have your horizon expanded if you always order the same thing, but there it is. It's a very popular way of consuming software.\n\nRails is not that. Rails is omakase."
}, {
  id: '2',
  title: "The Parley Letter",
  author: "d2h" ,
  date: new Date('12-24-2012'),
  excerpt: "My [appearance on the Ruby Rogues podcast](http://rubyrogues.com/056-rr-david-heinemeier-hansson/) recently came up for discussion again on the private Parley mailing list.",
  body: "A long list of topics were raised and I took a time to ramble at large about all of them at once. Apologies for not taking the time to be more succinct, but at least each topic has a header so you can skip stuff you don't care about.\n\n### Maintainability\n\nIt's simply not true to say that I don't care about maintainability. I still work on the oldest Rails app in the world."  
}];

將來,您應該在堆棧跟蹤的其余部分中發布錯誤並指出錯誤發生在哪一行。 當我們不知道錯誤發生在哪里時,對於我們來說很難找到錯誤。

幸運的是,您的代碼並不太復雜,而且我已經看到足夠的Ember代碼來猜測您正在模型上調用舊方法。 App.Post.find()以來不建議使用App.Post.find()查找記錄(並且看起來它也已被刪除)。 您應該改用this.get('store').find('post')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM