【问题标题】:Angular2/TypeScript - loading twice when using navigateByUrl to redirect componentAngular2/TypeScript - 使用 navigateByUrl 重定向组件时加载两次
【发布时间】:2016-11-20 03:09:48
【问题描述】:

我想实现登录功能,点击登录按钮后,当前组件可以导航到另一个组件。

我的.ts和.html文件如下所示

login.component.ts

login.component.html

问题是:当我使用 npm start 监控更改时,expiryPage(这是我要重定向到的目标)因为要加载两次。
第一次加载组件时,url 看起来像

http://localhost:3000/expiryPage?

然后页面会很快刷新,url会被修复,比如

http://localhost:3000/expiryPage

使用 npm 时似乎可以工作,但是当我使用 google chrome 应用程序 “Web 服务器” 运行网络时,它在页面上给了我一个 entry not found 和错误消息 @ 987654326@

对这个问题有什么想法吗?我已经搜索了几个小时的解决方案
非常感谢

【问题讨论】:

    标签: typescript navigation components angular2-routing


    【解决方案1】:

    我终于从Angular2 router.navigate refresh page找到答案了

    希望对购物车中的人有所帮助

    【讨论】:

      猜你喜欢
      • 2017-02-20
      • 1970-01-01
      • 2017-06-10
      • 1970-01-01
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多