我想在我的应用程序中拥有一个布局页面(使用 Ionic v2 构建)。由于我希望每个页面上都有导航栏和侧边菜单,因此我认为没有必要将它们添加到项目的所有页面中,对吗?
例如:ASP.NET 有网站的母版页,其中包含每个页面上必须存在的组件。
有谁知道是否有一种简单的方法可以做到这一点?
最佳答案
I think it's unnecessary to add those to all the page's of my project, right?
侧边菜单内容只需在 app.html
文件中添加一次。但关于导航栏,正如您在 this SO post 中看到的那样,@mhartington(来自 Ionic 团队)说:
There is no way to create a global ion-navbar, as this is done on purpose. The point of having a navbar defined for each component is so that we can properly animate the titles, navbar background color (if you change them) and animate other properties needed.
关于创建自定义指令以避免重复 ion-navbar html 代码(我猜这就是您的想法):
That will still creat errors with how angular2 content projection works. We have several issues that have been open when people try this and the best answer is to not do it.
关于javascript - Ionic v2 中的布局页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42574313/