【发布时间】:2020-09-04 04:38:44
【问题描述】:
我有一个角度应用程序,其中一个组件根据所选选项显示数据。 现在从另一个页面中,我需要在新选项卡中打开此页面。 我尝试使用 href 和 window.open(url) 但每当我在新标签页中打开 url 时,所有数据都会被重置。
我正在尝试实现一种方式,使我的选择也保留在新标签中。
goToNewTab(){
this.selectedYear = [2020,2021,2022]
const url = "demo-project/checkBirth"
window.open(url, '_blank')
}
这里我也需要“this.selectedYear”才能转到新标签。
请注意:- 我无法更新 url 并在其中传递所选年份的任何查询参数。网址必须相同。
【问题讨论】:
-
可以使用片段吗,比如
demo-project/checkBirth#selectedYear=2020? -
no 不能更改 url @Thomas 中的任何内容
-
添加到 sessionStorage 或 LocalStorage 中
标签: javascript html angular frontend angular8