问题
Edit: Shortened and clarified the problem.
What's the most practical way to achieve the following in my Meteor app using Iron Router:
- Condition A - show template A
- Condition B - show template B
- otherwise - show template C
for a single URL, so that a user cannot directly enter "/url-a" or "/url-b" or "url-c" to select the view/template explicitly.
回答1:
Given the limited information you've provided, I can't think of anything shorter than the following logic in your route:
if ( A ) this.render('templateA');
else if ( B ) this.render('templateB');
else this.render('templateC');
This assumes that you have a route with a layout and you're rendering a template into that layout.
But given this answer is so trivial I suspect you're asking a different question altogether.
来源:https://stackoverflow.com/questions/32520801/routing-for-multi-step-process