sma*_*use 5 url-routing plunker angular2-routing angular2-router3 angular
我试图用Angular2路由器重现我的问题,但我不能在Plunker中创建我的项目的工作副本.
这是我的尝试:https://plnkr.co/edit/1lpoYP4qlBZLuqZHW7Ft
我在index.html文件中使用了以下代码行,使路径路径与Plunker的运行环境一起使用,并使用我的''默认路径.
<script>document.write('<base href="' + document.location + '" />');</script>
Run Code Online (Sandbox Code Playgroud)
为什么我还在get这个错误?
Phi*_*ief 10
你的plnkr有一个小错字:
loadChildren:'app/fist -section.module#FirstSectionModule'}
可能是第一 ;)
还有一个问题:即使是孩子也需要一个空路''.所以不要写作
children: [
{ path: 'first-section', loadChildren: 'app/first-section.module#FirstSectionModule' }
]
你应该添加一个空路径并重定向到first-section-path,如下所示:
children: [
{ path: '', redirectTo: 'first-section'},
{ path: 'first-section', loadChildren: 'app/fist-section.module#FirstSectionModule' }
]
Run Code Online (Sandbox Code Playgroud)
这是纠正的plnkr:
https://plnkr.co/edit/9fMwx0?p=preview
我注意到使用最新版本的angular(2.4.1)时,不再需要为子路径使用空路径.
我用最新的角度2.4.1版本更新了plunker:PLUNKER.该示例现在没有空路径运行.
| 归档时间: |
|
| 查看次数: |
29026 次 |
| 最近记录: |