[英]Ember not able to configure routes correctly
我在添加簡單路由時遇到問題,不確定如何調試它。
我指定的路線如下
Videos.Router.map(function({
this.resource('videos', {path:'/');
this.route('forms');
})
Videos.FormsRoute = Ember.Route.extend({
renderTemplate: function({
this.render({controller: 'forms'});
}
})
我也有一個表單模板,如下所示:
<script type="text/x-handlebars" data-template-name="forms">
但是,當我導航到url / forms時,出現找不到頁面的錯誤。
有什么想法可以開始解決這個問題嗎?
要使用/forms
等非哈希網址,您需要將Ember的位置配置為使用html5位置。
App.Router.reopen({
location: 'history'
});
您還需要配置服務器以呈現訪問/forms
時呈現的相同index.html。 這將根據您的服務器而有所不同。
對於apache,您將需要一個mod_rewrite
規則。 對於Rails之類的東西,您需要添加一條catch all路由才能使用HomeController
的索引頁。 在route.rb的末尾類似這樣的內容,
root :to 'home#index'
match "/*path" => 'home#index'
這告訴服務器,任何與您之前的路由不匹配的內容都應使用HomeController.index
方法或呈現應用程序html的特定控制器呈現。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.