我有一个带有路由配置的单页应用程序,如下所示:
<more-route name="projects" path="/projects">
<more-route name="projectroot" path="/noProjectSelected"></more-route>
<more-route name="projectname" path="/:projectname">
<more-route name="edittask" path="/edit/:task"></more-route>
<more-route name="newtask" path="/newtask"></more-route>
</more-route>
</more-route>
现在我有一个带有以下more-route-selector
标记的自定义元素
<more-route-selector flex vertical layout>
<core-pages flex vertical layout>
<projects-view route="projects" flex></projects-view>
<section route="search">
<div>Search Page</div>
</section>
<section route="calendar">
<div>Calendar Page</div>
</section>
<section route="settings">
<div>Settings Page</div>
</section>
</core-pages>
</more-route-selector>
在projects-view
元素中,我只有另一个more-route-selector
来显示嵌套页面。代码如下:
<more-route-selector selectedParams="{{params}}" flex fullbleed vertical layout>
<core-pages flex fullbleed vertical layout>
<div route="projectroot" flex>Hello</div>
<task-list projectname="{{params.projectname}}" route="projectname" flex></task-list>
<add-modify-task processType="add" projectname="{{params.projectname}}" route="newtask" flex></add-modify-task>
<add-modify-task processType="modify" projectname="{{params.projectname}}" task="task" route="edittask" flex></add-modify-task>
</core-pages>
</more-route-selector>
问题是控制台显示以下错误:Exception caught during observer callback: TypeError: Cannot read property 'projectname' of undefined
。我知道我需要传递那个projectname
param。但那时我没有那个参数。
我希望它默认显示route=projectroot
部分。我的代码中有什么东西我做错了吗?有什么方法可以摆脱错误。
提前致谢