我在angular.json样式数组中包含了一些样式,如下所示:
"styles": [
"src/styles.css",
"node_modules/primeicons/primeicons.css",
"node_modules/primeng/resources/themes/omega/theme.css",
"node_modules/primeng/resources/themes/bootstrap/theme.css",
"node_modules/primeng/resources/primeng.min.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/font-awesome/css/font-awesome.css"
]
但它不是采摘的样式,因为我看不到primeng表格样式和其他样式。
虽然如果我在styles.css文件中导入样式,效果很好,如下所示:
@import '../node_modules/primeng/resources/themes/omega/theme.css';
@import '../node_modules/primeng/resources/themes/bootstrap/theme.css';
@import '../node_modules/primeicons/primeicons.css'
我相信我们可以使用上述任何一种方法,如果这不正确,请告诉我。
我还重新启动了ng服务多次。
任何帮助表示赞赏。谢谢你的期待。
我从angular.json中使用了angular 6,这很明显,也让我知道是否必须共享任何其他代码或信息。
最佳答案
您也可以按原样保留.angular.cli.json
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.css",
"../node_modules/font-awesome/css/font-awesome.min.css",
"../node_modules/primeng/resources/primeng.min.css",
"../node_modules/primeng/resources/themes/omega/theme.css",
"styles.scss"
],
样式的顺序很重要。在上面的例子中。 Bootstrap css将首先应用,然后是primeng主题,最后是您的自定义scss文件。最终,styles.scss将覆盖所有其他样式。无需在任何地方导入。
关于css - 样式不是从angular.json样式数组angular 6中挑选的,但是可以与styles.css中的导入一起正常工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51998505/