0

Emberのpre4リリースで作業しようとしていますが、ルーターでスタックしています。

というエラーが表示されますUncaught TypeError: Cannot Call method 'map' of undefined

関連するコード:

App.Router.map(function() {
  this.route("about", { path: "/about" });
  this.route("favorites", { path: "/favs" });
});

相対的なドキュメント

Ember.jsとjQueryをロードしました。Emberpre4もエラーをスローしますUncaught TypeError: Object prototype may only be an Object or null

私は何か間違ったことをしていますか?ガイドは更新されていませんか?


私がこれまでに持っているコード:

window.App = Ember.Application.create({
  ApplicationView: Ember.View.extend({
    templateName: 'application'
  }),
  ApplicationController: Ember.Controller.extend({
  }),

  SiteView: Em.View.extend({
    templateName: 'site-template'
  }),
  SiteController: Em.ArrayController.extend(),

});

App.Router.map(function() {
  this.route("about", { path: "/about" });
  this.route("favorites", { path: "/favs" });
});
4

1 に答える 1

1

あなたが投稿したコードに問題はありません。jsbin で実行でき、「サイト」をデフォルト ルートとして追加した後、アプリは動作しているように見えます。

App = Ember.Application.create({
  ApplicationView: Ember.View.extend({
    templateName: 'application'
  }),
  ApplicationController: Ember.Controller.extend({
  }),

  SiteView: Em.View.extend({
    templateName: 'site-template'
  }),
  SiteController: Em.ArrayController.extend()

});

App.Router.map(function() {
  this.route("site", { path: "/" });
  this.route("about", { path: "/about" });
  this.route("favorites", { path: "/favs" });
});

<script type="text/x-handlebars" data-template-name="site-template">
  This is the site template
</script>

<script type="text/x-handlebars">
  This is the application template
  {{outlet}}
</script>

作業コピーについてはjsbinを参照してください。

私の最善の推測では、互換性のないバージョンの jQuery または handlebars.js がないためにエラーが発生している可能性があります。どちらも ember を実行するために必要です。また、開発中は必ずember-1.0.0-pre.4.jsを使用してください! ember-1.0.0-pre.4.min.js の代わりに。最小化されたバージョンは本番環境での使用に最適化されているため、この種の問題を見つけやすくするための役立つデバッグ メッセージは含まれていません。

于 2013-01-24T04:44:24.420 に答える