ionic-team / ionic-team/ionic-framework

feat: fallback / catch all route for ion-router

Ouverte
#24,726 5 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
package: core type: feature request
Langage dominant
TypeScript
Étoiles
52.7k
Forks
13.3k
Merge moyen
1 j 15 h
PR mergées (30 j)
51

Description

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already include this feature request, without success.

### Describe the Feature Request

This is a follow up for #18687.

The only way to do a fallback route as of today is to use `url="/:any"` :
```html



```

This "trick" is not documented.

### Describe the Use Case

Most app need to display a 404 page or redirect the user to a sensible page when the url is not found.

### Describe Preferred Solution

`` would be nice as it would be consistent with with ion-route-redirect [usage of *](https://ionicframework.com/docs/api/route-redirect#usage).

Whatever solution is picked should be documented as it is a common use case.

### Describe Alternatives

There are several solution:

1. Keep the current `` but document it
2. Use `` this would be consistent with ion-route-redirect [usage of *](https://ionicframework.com/docs/api/route-redirect#usage)
3. Use `` (i.e. no url)

### Related Code

_No response_

### Additional Information

I'm up to help implement and/or document this once a solution is picked.

What do you think ?

Bonus question: what should we do when multiple catch all routes are defined ? My preference would be to trigger an error as there should be no reason to be in this situation. Note that as of today the first catch-all route would be used but the current behavior seems brittle as it is mostly an implementation detail and not covered by tests.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.