ionic-team / ionic-team/ionic-framework

feat: fallback / catch all route for ion-router

Đang mở
#24,726 5 bình luận 1 reaction 0 người được giao Xem trên GitHub
package: core type: feature request
Ngôn ngữ chính
TypeScript
Star
52.7k
Fork
13.3k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
51

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.