ionic-team / ionic-team/ionic-framework

feat: fallback / catch all route for ion-router

Offen
#24,726 5 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
package: core type: feature request
Vorherrschende Sprache
TypeScript
Sterne
52.7k
Forks
13.3k
Ø Merge
1 T. 15 Std.
Gemergte PRs (30 T.)
51

Beschreibung

### 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.