ionic-team / ionic-team/ionic-framework

bug: rootParam Ignored When Using Ion-Router

Đang mở
#24,310 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
package: core type: bug
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 report this problem, without success.

### Ionic Framework Version

- [ ] v4.x
- [X] v5.x
- [ ] v6.x

### Current Behavior

The `rootParams` parameter for `ion-nav` can be used to pass parameters to the root page (which has been defined using the `root` attribute). When the `root` attribute is removed from the `ion-nav` tag and an `ion-router` element is used to determine the root page based on the URL, the `rootParams` parameter for `ion-nav` is ignored.

[This fiddle](https://jsfiddle.net/fL7rdvjp/1/) is an example of the use of `rootParams` when the root page is specified using the `ion-nav` `root` attribute.

[This fiddle](https://jsfiddle.net/fL7rdvjp/2/) is an example of how the `rootParams` parameter cannot be read when an `ion-router` element is used to determine the root page.

### Expected Behavior

The first page should have the contents `a: 1, b: 2`

### Steps to Reproduce

Use the following HTML body:
```html




```

WIth the following JavaScript:
```javascript
const nav = document.querySelector('ion-nav');

class NewPage extends HTMLElement {
async connectedCallback() {
this.innerHTML = `






Root Page


a: ${this.a}, b: ${this.b}



New Page

`;

const btn = this.querySelector('ion-button');
btn.addEventListener('click', () => {
nav.push('new-page', { a: this.a + 1, b: this.b + 1});
})
}
}
customElements.define('new-page', NewPage);

nav.rootParams = { a: 1, b: 2 };
```

The root page (or first page that is displayed) will have the contents `a: undefined, b: undefined`, which indicates that `rootParams` was either unused or overwritten.

### Code Reproduction URL

_No response_

### Ionic Info

_No response_

### Additional Information

_No response_

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.