ionic-team / ionic-team/ionic-framework

feat: fallback / catch all route for ion-router

オープン
#24,726 コメント 5 件 リアクション 1 件 担当者 0 名 GitHub で見る
package: core type: feature request
主要言語
TypeScript
スター
52.7k
フォーク
13.3k
平均マージ
1日 15時間
マージ済み PR(30日)
51

説明

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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。