Aurelia BrowserSync 重新加载不适用于所有路线

Aurelia BrowserSync reload not working for all routes

我正在开发 aurelia 应用,这是路由配置

configureRouter(config, router) {
    config.title = 'Title';
    config.map([
      {route: [''], name: 'home', moduleId: 'home', nav: false, title: 'home'},
      {route: 'customers', name: 'customers', moduleId: './pages/customers/customers', nav: false, title: 'customers'},
      {route: 'customers/:id', name: 'custDetail', moduleId: './pages/customers/custDetail', nav: false, title: 'customer Details'}
    ]);
    config.options.pushState = true;
    this.router = router;
  }

在主页上点击一个按钮,我调用

 this.router.navigateToRoute('customers', {tags: this.tags});

如果我修改 customers/:id 页面,浏览器重新加载不起作用,显示错误

Cannot GET /customers/2

这是它应该如何工作吗?

谢谢!

这里的问题是您的服务器未配置为使用 pushState,这是一种避免使用 url 散列进行路由的特殊模式。 (正如我们在评论中讨论的那样),以下行是造成问题的原因。

// this should only be used when you have a pushState enabled server
config.options.pushState = true;

您可以删除它或将其设置为 false。