我正在尝试创建一个用户配置文件页面的路径,这个页面必须是"/:username",但是它不起作用。最后一行对此进行了描述。孩子们的路线似乎不适合那些有空路的父母。
app.js
configureRouter(config, router){
config.title = 'Dreampper';
//config.options.pushState = true;
config.map([
{ route: '', moduleId: 'home'},
{ route: 'login', moduleId: './components/account/login', name: 'login'},
{ route: 'register', moduleId: './components/account/register', name: 'register'}
]);在我的home.js中有:
{ route: '', moduleId: './components/timeline/timeline', name: 'timeline' },
{ route: 'welcome', moduleId: './components/account/welcome', name: 'welcome' },
{ route: 'account/EmailConfirmation/:user/:code', moduleId: './components/account/email-confirmation', name:'Email confirmation' },
{ route: ':username', moduleId: './components/profile/profile', name: 'profile' }有人能帮我吗?我不想使用重定向,因为重定向使URL不是空的"localhost/“。
发布于 2016-12-27 14:54:20
配置路由器时使用mapUnknownRoutes函数。我没有测试这个,但是你应该能做这样的事情。也请考虑法比奥的建议--这是个好建议。但如果你真的想这么做..。
config.mapUnknownRoutes({ redirect: '#/' });
router.configure(config => {
config.mapUnknownRoutes(instruction => {
//check instruction.fragment
//set instruction.config.moduleId
});
});基本上,您需要查看instruction.fragment以获得指定的实际路由,然后将其重定向到具有参数的特定路由,作为给定的任何路由。
https://stackoverflow.com/questions/41334151
复制相似问题