Dan*_*cia 5 javascript web-applications url-routing ember.js
Ember允许在路由器上指定根URL:http://emberjs.com/guides/routing/#toc_specifying-a-root-url
App.Router.reopen({
rootURL: '/blog/'
});
Run Code Online (Sandbox Code Playgroud)
有没有办法指定动态URL,如:/:region/:locale/?
该rootURL分配似乎只接受一个字符串.
资产(包括Ember)正在从像这样的公共目录加载/assets/.
您可以rootURL在Router.init方法中动态设置,例如
App.Router.reopen({
init: function() {
// set rootURL using regex to extract appropriate
// rootURL based on current window location
this.set('rootURL',
window.location.pathname.match('/[^/\]*/[^/\]*/')[0]);
this._super();
});
Run Code Online (Sandbox Code Playgroud)