在Angular 2中重新加载页面时保留数据

编程入门 行业动态 更新时间:2024-10-25 06:31:46
本文介绍了在Angular 2中重新加载页面时保留数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Angular 2应用程序中,我将一些数据从HomeComponent传递到PageComponent,然后将其保存到PageComponent内部的变量中.现在,当我刷新页面时,我需要保留这些数据.目前,我正在使用会话存储,但我想知道是否有更好的方法来实现此目的.

In my Angular 2 app, I pass in some data to a PageComponent from my HomeComponent which is then saved to a variable inside the PageComponent. Now when I refresh the page I need this data to be retained. Currently I am using session storage, but I was wondering if there is a better way to implement this.

推荐答案

不,在这种情况下没有其他方法.刷新后,所有临时内存都消失了.如您所说,您正在执行会话存储.您可以继续.您可以选择以下内容.

Nope, There isn't a other way in this context. Once you refresh all the temporary memory is gone. As you said you are performing session-storage. You may continue with that. You may choose the below.

  • LocalStorage
  • 饼干
  • 会话
  • 区别和重要性:如何将令牌存储在Angular 2的本地存储或会话存储中?

    更多推荐

    在Angular 2中重新加载页面时保留数据

    本文发布于:2023-11-01 19:58:10,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1550262.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:加载   页面   数据   Angular

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!