如果查询参数值是默认值,则Ember不会在url中显示查询参数。但是我想展示一下。是否可以将这种行为更改为显示而不是隐藏?
App.IndexController = Ember.ArrayController.extend({
queryParams: ['type'],
type: "horror" // the default value, won't appear in URL or params
})
本指南部分介绍了默认值和序列化。不幸的是,它没有提供包括默认值的方法,而且我不确定是否有开箱即用的方法。
但是,有一个小技巧。null
设置查询参数后,不要在路由中使用和设置默认值,而是在路由中使用并设置默认值。从您的角度来看,这使Ember认为它不是默认值。
App.IndexRoute = Ember.Route.extend({
resetController: function(controller) {
controller.set('type', 'horror');
return this._super.apply(this, arguments);
}
});
App.IndexController = Ember.ArrayController.extend({
queryParams: ['type'],
type: null
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句