我不是100%确定的,但是路线可能是一次性建立并重用的,至少那些属于导航模型的部分(nav === true
)。这意味着您不能使用nav
的动态表达式,因为它只会被处理一次。
如果您只是需要此选项才能在导航栏中显示路线,则可以使用settings
property创建解决方法以某种方式标记路线并在创建导航栏时进行条件检查。
{
route: 'aRoute',
moduleId: 'modules/something/mySite,
nav: true,
title: 'mySite',
settings: { occasionallyVisible: true } // add your own properties here...
}
我用settings.occasionallyVisible
属性,但你可以添加任何你喜欢的东西。如果没有settings
财产或settings.occasionallyVisible
是falsy OR cond
是true
<li repeat.for="route of router.navigation"
if.bind="!route.settings || !route.settings.occasionallyVisible || cond">
<a href.bind="route.href">${route.title}</a>
</li>
导航路线将被显示。当然,cond
就是你需要的那种条件。
不优雅,但它应该完成工作,直到你得到更好的答案:)
你解决了这个问题吗?现在我们见面了。 – sibi