我用rappidjs构建了一个菜单视图组件,其中包含一个条目列表。我还有一些模块。
我想让模块注册他们的菜单项。我想构建一个管理器或一个集合,但这对我来说似乎是一种沉重的方式。有没有简单的方法?
实现可以在这里找到。
http://try.rappidjs.com/project/52b0d1e13bce060342000013
发布于 2013-12-20 17:08:31
查看rappidjs.com网站,它还使用了一个与ModuleLoader相结合的菜单。
在https://github.com/rappid/rappidjs.com/blob/master/public/app/Index.xml中,菜单是用
<nav>
<ui:ItemsView items="{pages}" tagName="ul" class="nav">
<js:Template name="item">
<li selected="{isPageSelected(item)}">
<a href="${item.link}">${item.label}</a>
</li>
</js:Template>
</ui:ItemsView>
</nav>
isPageSelected
的实现请参考https://github.com/rappid/rappidjs.com/blob/master/public/app/IndexClass.js。
对于可重用的解决方案,您可以使用一个菜单组件来获取ModuleLoader
as属性,并动态地从moduleLoader.$modules
数组中获取所有已注册的模块。
我们还没有构建这样的组件,因为一个菜单可以包含比ModuleLoader中注册的项更多的项。
https://stackoverflow.com/questions/20646214
复制相似问题