Hostlistener 无法在 Firefox 中工作,但可以在 Chrome 和 Edge 中工作

问题描述 投票:0回答:1

在主机侦听器内部检查 url 并进行区分。

根据路径更改我正在加载组件

在其他环境下可以工作,但在firefox下不行

我的代码:

@HostListener ("window:loadurl", ["$event"])
onLoadUrl (event) {

    try {
    let path = event.target.location.href;
    Splitting and getting the path here
    if(path[1].includes("/address")){
    Load address component 
    }
    if(path[1].includes("/marks")){
    Load marks component 
    }
    
}

但它在 Chrome 和 Edge 中工作正常,但在 Firefox 中却不行

请帮助我编写这段代码

提前致谢

angular firefox
1个回答
0
投票

您可以尝试一下

load
活动吗?

@HostListener ("window:load", ["$event"]) // <- changed here
onLoadUrl (event) { 

    try {
    let path = event.target.location.href;
    Splitting and getting the path here
    if(path[1].includes("/address")){
    Load address component 
    }
    if(path[1].includes("/marks")){
    Load marks component 
    }
    
}
© www.soinside.com 2019 - 2024. All rights reserved.