简体   繁体   English

Angular 4侧栏

[英]Angular 4 Sidebar

I'm trying to create a sidebar with Angular, and the only one I could find was ng-sidebar by arkon available here: https://github.com/arkon/ng-sidebar . 我正在尝试使用Angular创建侧边栏,而我唯一能找到的是arkon的ng-sidebar,可在这里找到: https : //github.com/arkon/ng-sidebar The log output after installation is: 安装后的日志输出为:

+-- UNMET PEER DEPENDENCY @angular/core@4.3.6    
+-- UNMET PEER DEPENDENCY @angular/http@4.3.6    
`-- ng-sidebar@6.0.1    

It seems to me that my version of Angular is incompatable with this component. 在我看来,我的Angular版本与此组件不兼容。 I've tried deleting my node_modules, clearing the cache, and reinstalling as others have done, but it's not working for me. 我曾尝试删除自己的node_modules,清除缓存,然后像其他人一样重新安装,但这对我不起作用。 Is there some other solution, or is there a better or alternative way for me to implement a sidebar? 是否有其他解决方案,或者我有实现边栏的更好或替代的方法?

On a related note, I am also seeing the following 2 warnings, but I don't think it's affecting anything. 在相关说明中,我还看到了以下2条警告,但我认为它不会影响任何警告。 Should I do anything about these warnings? 我应该对这些警告采取任何措施吗?

npm WARN angular2-jwt@0.1.28 requires a peer of @angular/core@^2.0.0 but none was installed.  
npm WARN angular2-jwt@0.1.28 requires a peer of @angular/http@^2.0.0 but none was installed.  

--------------------Results of "ng -v" below---------------------------- --------------------以下“ ng -v”的结果---------------------- ------

@angular/cli: 1.3.2    
node: 6.11.0    
os: win32 x64    
@angular/animations: 4.3.6    
@angular/common: 4.3.6  
@angular/compiler: 4.3.6  
@angular/compiler-cli: 4.3.6  
@angular/core: 4.3.6  
@angular/forms: 4.3.6  
@angular/http: 4.3.6  
@angular/platform-browser: 4.3.6  
@angular/platform-browser-dynamic: 4.3.6  
@angular/platform-server: 4.3.6  
@angular/router: 4.3.6  
@angular/cli: 1.3.2  

You have a few options here: 您可以在此处选择以下几种:

  1. Material design. 材料设计。 They have a sidenav that would probably work for you ( https://material.angular.io/components/sidenav/overview ). 他们有一个可能对您有用的sidenav( https://material.angular.io/components/sidenav/overview )。

  2. bootstrap. 引导程序。 You could make a col-md-1 (or whatever size you want) in your main div. 您可以在主div中创建col-md-1 (或任意大小)。

  3. make that out of date lib work. 使过时的lib工作。 More than likely, you might be able to ignore the warnings, but if it isn't working, I'm sure the owner of that repo would love for you to contribute. 您很有可能可以忽略警告,但是,如果该警告不起作用,我相信该回购协议的所有者将很乐意为您提供帮助。

  4. write your own. 自己写。 This may be your best option as you could learn a few things about angular and layouts (not assuming you don't know, just saying we can all learn). 这可能是您最好的选择,因为您可以学习一些有关角度和布局的知识(不是假设您不知道,只是说我们都可以学习)。

For writing your own, consider a flexbox or a grid like bootstrap uses. 要编写自己的脚本,请考虑使用flexbox或类似bootstrap的网格。 You can then consider adding a @Output() and EventEmitter to cover things like an open or toggle action. 然后,您可以考虑添加@Output()EventEmitter来覆盖诸如打开或切换操作之类的内容。

Ended up needing to update my package.json dependencies manually. 最终需要手动更新我的package.json依赖项。 I verified the new values with 'npm outdated'. 我使用“ npm已过时”验证了新值。 Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM