Ember中有没有办法在网址中添加可选段?
这就是/:locale/reservations/:id
中的:locale是可选的,以便/fr/reservations/12345
和/reservations/12345
一样工作?
我当前的路由器如下所示:
App.Router.map ->
@resource 'reservation', path: '/*locale/reservations/:id', ->
@route('status', path: '/status')
答案 0 :(得分:0)
点击此处emberjs using multiple paths / urls for one route或serialize
尝试以下内容:
serialize: function(model, params) {
var locale, id;
if(model.locale)
locale = model.locale;
else
locale = '';
id = model.id;
return { locale: locale, id: id };
}