gpt4 book ai didi

javascript - 如何刷新 Angular 组件

转载 作者:行者123 更新时间:2023-11-30 19:06:17 25 4
gpt4 key购买 nike

我正在使用 ionic 4 构建一个移动应用程序,它使用 aren 两种语言,菜单抽屉是预先构建的成分。

因此我需要刷新抽屉组件以根据 dom 方向 rtlltr

获取正确的样式

我现在正在做的只是 location.reload 重新加载整个应用程序,但我认为这不是一个好的方法

最佳答案

最简单的方法是调用 ngOnInit

fn() {
this.ngOnInit();
}

或者试试这个

this.router.navigateByUrl('/RefreshComponent', { skipLocationChange: true })
.then(() => {
this.router.navigate(['Your actualComponent']);
});

关于javascript - 如何刷新 Angular 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58954414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com