Angular 2-PrimeNg样式不起作用 [英] Angular 2 - PrimeNg style not working

查看:107
本文介绍了Angular 2-PrimeNg样式不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照说明通过运行npm install primeng --save然后将我需要的内容导入app.module.ts文件中来安装primeng,例如:

I've followed the instruction to install primeng by running npm install primeng --save then importing what I need in the app.module.ts file, for example:

import {CheckboxModule} from 'primeng/primeng';  

...

imports: [
    CheckboxModule,
  ],...

然后我将样式表添加到index.html文件中:

I then add the style sheets to the index.html file:

<head>
  ...
    <link rel="stylesheet" type="text/css" href="../node_modules/primeng/resources/themes/omega/theme.css" />
    <link rel="stylesheet" type="text/css" href="../node_modules/primeng/resources/primeng.min.css" />
    <link rel="stylesheet" type="text/css" href="../node_modules/font-awesome/css/font-awesome.min.css" />
</head>

我的IDE可以找到文件位置(通过按住ctrl并单击href值),但浏览器找不到该文件位置(404错误).

My IDE can find the file location (by holding ctrl and clicking on the href value) but it is not found by the browser (404 error).

我已复制了复选框示例( http://www.primefaces.org/primeng/#/checkbox ),并将其添加到我的一个组件中,但是样式与普通复选框相同.

I've copied the checkbox example (http://www.primefaces.org/primeng/#/checkbox) and added it to one of my components but the style is the same as a normal checkbox.

此外,不会引发其他错误.

Also, no other errors are thrown.

是否应将样式添加到另一个文件?我不确定为什么它不起作用.

Should the styles be added to another file? I'm not sure why it's not working.

推荐答案

我找到了

I found a tutorial that uses PrimeNg with Angular CLI that worked for me.

我将font-awesome.min.css样式表添加到index.html.

I added the font-awesome.min.css stylesheet to index.html.

然后将我想要的主题(例如"../node_modules/primeng/resources/themes/omega/theme.css",)放入"styles" [...]部分中的angular-cli.json文件.

Then the theme I wanted (e.g. "../node_modules/primeng/resources/themes/omega/theme.css",) to angular-cli.json file in the "styles" [...] section.

这篇关于Angular 2-PrimeNg样式不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆