在路线urlFor()
中,我可以使用/1/1/orders
生成URL。但我无法在应用程序路由中生成URL。
因此此代码不起作用:
var routeName = "scope.purchase.invoice";
var dynamicSegments = { scopeId: 1, scopeData: 2, invoiceId: 3, pageSize: 20, pageIndex: 1 };
var url = this.router.urlFor(routeName, 1, 2, 3, 10, 1);
console.log("inside generated url", url);
为此
router.js
:this.route("scope", { path: '/:scopeId/:scopeData' }, function(){
this.route("purchase", function(){
this.route("invoice", { path: '/:invoiceId/:pageIndex/:pageSize' });
})
});
这是参考文献ember-twiddle
最佳答案
const url = this.router.urlFor(routeName, dynamicSegments.scopeId, dynamicSegments.scropeData, dynamicSegments.invoiceId, dynamicSegments.pageSize, dynamicSegments.pageIndex);