在主机侦听器内部检查 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 中却不行
请帮助我编写这段代码
提前致谢
您可以尝试一下
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
}
}