Sails.js-如何将顶级导航移动到组件? [英] Sails.js- how to move the Top nav to a component?
本文介绍了Sails.js-如何将顶级导航移动到组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要具有很多额外功能和灵活性的顶级导航仪.我也不想我的layout.ejs
变成一团糟.因此,我将顶级导航移到一个组件中,并希望在这里分享我的操作方式.
I needed a top-nav with a good amount of extras and flexabliltiy. I also didnt want my layout.ejs
to become a tangled mess. So I moved my top-nav into a component and wanted to share how I did it here.
推荐答案
- 在
assest/js/components/
中创建一个新组件 (我查看Sails应用程序随附的现有组件以供参考)我将其命名为masthead
- 在组件中建立导航栏
- 删除了
layout.ejs
中对top-nav的任何提及
- 将
<masthead></masthead>
添加到将具有该顶级导航的所有HTML文件 - Create a new component in
assest/js/components/
(I look at the existing components that come with the Sails app for reference) I named minemasthead
- Built my nav-bar in the component
- Removed any mention of the top-nav in
layout.ejs
- Added
<masthead></masthead>
to all HTML files that will have this top-nav
这还有一个额外的好处,就是可以将Sails_Locals导航到导航栏.
This also has the added benefit of being able to get your Sails_Locals on to your nav-bar.
这篇关于Sails.js-如何将顶级导航移动到组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文