Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript this.router.routeReuseStrategy.shouldReuseRoute=()=>;虚假的;_Javascript_Angular_Routes - Fatal编程技术网

Javascript this.router.routeReuseStrategy.shouldReuseRoute=()=>;虚假的;

Javascript this.router.routeReuseStrategy.shouldReuseRoute=()=>;虚假的;,javascript,angular,routes,Javascript,Angular,Routes,为了使组件UI每次都更新,我应用了这类行。但在其他一些情况下,如果应该重用路由,它将开始刷新页面事件 我们如何克服这个问题 实际上,在我的应用程序中,左面板中有三个选项卡。在每个选项卡中都有一些列表单击列表项可打开右侧面板上的内容。但在其中一个列表中,有一个常见的UI正在打开某些列表项,但问题是,当我们不应用上述代码时,UI不会得到更新。但是,如果我们应用了代码,那么每次单击其他列表项时,UI都会更新。但问题是,当我们应用这段代码时,每当我们单击不同选项卡中的其他列表时,它就会开始刷新页面,但情

为了使组件UI每次都更新,我应用了这类行。但在其他一些情况下,如果应该重用路由,它将开始刷新页面事件

我们如何克服这个问题

实际上,在我的应用程序中,左面板中有三个选项卡。在每个选项卡中都有一些列表单击列表项可打开右侧面板上的内容。但在其中一个列表中,有一个常见的UI正在打开某些列表项,但问题是,当我们不应用上述代码时,UI不会得到更新。但是,如果我们应用了代码,那么每次单击其他列表项时,UI都会更新。但问题是,当我们应用这段代码时,每当我们单击不同选项卡中的其他列表时,它就会开始刷新页面,但情况不应该是这样


如果我们应用此代码
this.router.RouterUseStrategy.shouldReuseRoute=()=>false那么我们如何在这个路由器下恢复这个功能呢?

我也有同样的问题,我更改了这一行:

this.router.routeReuseStrategy.shouldReuseRoute = () => false;

我甚至不知道这是否能很好地工作或者做同样的事情。

描述中没有关于您的实现的详细信息,但听起来您应该考虑更新url查询参数。看见
  // override the route reuse strategy
  this.router.routeReuseStrategy.shouldReuseRoute = function () {
    return false;
  };

  this.router.events.subscribe((evt) => {
    if (evt instanceof NavigationEnd) {
      // trick the Router into believing it's last link wasn't previously loaded
      this.router.navigated = false;
      // if you need to scroll back to top, here is the right place
      window.scrollTo(0, 0);
    }
  });