如何在导航之间保存页面状态

时间:2021-07-29 09:47:45

标签: angular angular12

我会保存从一个页面到另一个页面的导航之间的位置,例如,当我单击一个链接并从浏览器的左箭头返回时,我会将它返回到我单击进入视图的链接的位置。 我怎样才能在 Angular 中做到这一点? 谢谢

 <a [routerLink]="['/productfood']" [queryParams]="{idt: 1,idc:0,ids:0}" >
       <img src="assets/img/food.jpg" style="width:180px;height:100px;" StyleClass="img-category"/>
       <br/> Food
       </a>

1 个答案:

答案 0 :(得分:1)

我认为你可以使用本地存储或存储会话,会话存储参考MDN文档:https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sessions/restore enter image description here