javascript - 角度:重定向后重新加载页面
问题描述
我有一个重定向到另一个页面的功能,我希望在重定向后重定向页面也重新加载。
我想在重定向到登录页面后重新加载它。使用 'window.location.reload()' 重新加载当前页面,该页面是主页但不是登录页面。如何重新加载特定页面?
主页组件.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { FormGroup, FormBuilder, FormControl, Validators, Form } from '@angular/forms';
import { LoginComponent } from '../authentification/login/login.component';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
ngOnInit(): void {
}
constructor(private router: Router) { }
redirection(){
this.router.navigate(['/login']);
}
}
解决方案
你为什么不使用
redirection(){
window.location.href="yourpagedomain/login"
}
它将加载页面。
推荐阅读
- ios - 防止 UIButton showsTouchWhenHighlighted 更改 VoiceOver 描述
- pdf - 通过 Apps 脚本将工作表导出为 PDF(现在有些变化不再可搜索且文件大小更大)
- r - 关于 R 中的因子,levels() 与 labels() 有何不同?
- php - 为什么 www-data 需要执行权限才能将上传的文件写入目录?
- python - 修改 Dash Plotly 下拉菜单以操作多个绘图
- django - 如何将数据从 csv 文件导入到默认的 Django 用户模型?
- generics - 如何将实体或 DbSet 作为参数传递?
- amazon-s3 - 使用 s3 连接和 s3 钩子在 Airflow 上创建 boto3 s3 客户端
- java - Domino 子表单未将字段值传递给 JAVA 代理
- probability - 我如何计算以下的概率?