如何使用相同的 url 路由相同的页面并更新 Aurelia 中的内容
how to route the same page with same url and update content in Aurelia
例如:在同一页面查看协议列表和创建协议。我想重新加载
保存新 agreement.i 后的协议列表尝试此 this.router.navigate('/agreement/client/10') 但这不会加载新列表,因为它导航相同 url.
您可以使用事件聚合器,并在添加新协议时发布事件,并在事件触发时重新加载列表。
在您的 configureRouter
方法中,将 activationStrategy.replace
添加到需要此功能的路由:
import {activationStrategy} from 'aurelia-router';
export class MyClass {
configureRouter(config) {
config.map([{
route: 'my-route',
name: 'my-name',
activationStrategy: activationStrategy.replace,
title: 'My Title',
moduleId: 'myModule',
}]);
}
}
例如:在同一页面查看协议列表和创建协议。我想重新加载 保存新 agreement.i 后的协议列表尝试此 this.router.navigate('/agreement/client/10') 但这不会加载新列表,因为它导航相同 url.
您可以使用事件聚合器,并在添加新协议时发布事件,并在事件触发时重新加载列表。
在您的 configureRouter
方法中,将 activationStrategy.replace
添加到需要此功能的路由:
import {activationStrategy} from 'aurelia-router';
export class MyClass {
configureRouter(config) {
config.map([{
route: 'my-route',
name: 'my-name',
activationStrategy: activationStrategy.replace,
title: 'My Title',
moduleId: 'myModule',
}]);
}
}