[英]angular-cli@webpack with primeng 404 issues
I get the following errors in a starter project with angular2, angular-cli@webpack and primeng. 我在使用angular2,angular-cli @ webpack和primeng的初学者项目中遇到以下错误。 The only ui component from PrimeNG is a dropdown which renders and it has its values but no css theme is applied ever.(see errors below in regards to CSS).
PrimeNG中唯一的ui组件是一个下拉列表,它呈现并且它有值但是没有应用任何css主题。(请参阅下面关于CSS的错误)。 I am not sure why I get this error and have spent countless hours with no result so I am at a loss at this point.
我不知道为什么我会得到这个错误,花了无数个小时没有结果,所以我在这一点上不知所措。 Component was generated with ng command and ng serve runs the web server.
使用ng命令生成组件,ng服务运行Web服务器。 Anybody any idea?
有人有什么想法吗? I also have tried both node.js 6.5.0 and 4.5.0 (switching and managing them with nvm).
我也尝试过node.js 6.5.0和4.5.0(使用nvm切换和管理它们)。
Any help is appreciated deeply. 深深地感谢任何帮助。
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/node_modules/primeng/resources/primeng.min.css Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/src/app/resources/css/font-awesome-4.6.3/css/font-awesome.min.css Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/node_modules/primeui/primeui-ng-all.min.css Failed to load resource: the server responded with a status of 404
无法加载资源:服务器响应状态为404(未找到) http:// localhost:3000 / node_modules / primeng / resources / primeng.min.css无法加载资源:服务器响应状态为404(找不到) http:// localhost:3000 / src / app / resources / css / font-awesome-4.6.3 / css / font-awesome.min.css无法加载资源:服务器响应状态为404(未找到) http:// localhost:3000 / node_modules / primeui / primeui-ng-all.min.css无法加载资源:服务器响应状态为404
By the way now I posted the code in: https://github.com/GregHila/primeng-angular-cli . 顺便提一下,我发布的代码是: https : //github.com/GregHila/primeng-angular-cli 。
Under the src/
there should be a file styles.css
. 在
src/
应该有一个文件styles.css
。 I think you can import the styles here. 我想你可以在这里导入样式。
Eg.: 例如。:
@import '../node_modules/primeng/resources/primeng.min.css';
The other way is to mention them in the angular-cli.json
file in the styles
array. 另一种方法是在
styles
数组中的angular-cli.json
文件中提及它们。
If you are using the webpack branch, then node_modules
will not exist in the served directory. 如果您使用的是webpack分支,那么在服务目录中将不存在
node_modules
。 You will have to import the libraries you want to use, which will cause webpack to bundle them for you. 您必须导入要使用的库,这将导致webpack为您捆绑它们。 Alternatively modify
apps[0].scripts
and apps[0].styles
properties of angular-cli.json
like in https://github.com/angular/angular-cli#global-library-installation . 或者修改
angular-cli.json
apps[0].scripts
和apps[0].styles
属性,如https://github.com/angular/angular-cli#global-library-installation 。
看起来像1.0.0-beta.11-webpack.9-4也修复了这个bug
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.