angular - Starting out with SASS, SCSS and Bootstrap in Angular project
问题描述
I'm new to Bootstrap and SASS, so I'm hoping to get some info on how to configure it correctly and get started.
I have a (relatively) new Angular project created in Visual Studio 2019. Bootstrap is defined in package.json as follows:
"bootstrap": "^4.4.1",
so I was under the impression that I'll get the SASS stuff out of the box. Whenever I generate a component with "ng generate", a SASS file is also created, but when I try adding a simple class to the file, like so:
.nav-link {
width: 40px;
height: 40px;
}
it's not recognized and I get the following error:
Failed to compile.
Module build failed (from ./node_modules/sass-loader/dist/cjs.js): SassError: Expected newline.
... primary-nav\primary-nav.component.sass 1:11 root stylesheet
I realize that I'm missing configurations (?), and also - I'm confused as to what I'm supposed to use? SASS extension files? SCSS extension? Isn't SCSS just a "syntax to use SASS"?
I tried searching for similar questions/articles but didn't find a comprehensive explanation on how to get started and configure everything in this type of project.
any help (and/or pointing in the right direction) will be greatly appreciated. thank you!
EDIT - solution(s):
- needed to install
npm i node-sass
- in angular.json had to change this:
"schematics": {
"@schematics/angular:component": {
...
"style": "sass"
},
to this:
"style": "scss"
- changed extension of existing file(s) to
.scss
解决方案
Check that you have in angular.json:
"schematics": {
"@schematics/angular:component": {
...
"styleext": "scss"
},
and in package-lock.json:
"dependencies": {
...
"@angular-devkit/build-angular": {
...
"requires": {
....
"node-sass": "4.10.0",
"sass-loader": "7.1.0",
...
"node-sass": {
...
},
"sass-graph": {
...
},
"sass-loader": {
...
}
The versions are just for example, I just wrote how my config looks regarding SASS
推荐阅读
- r - R如何用因子IV绘制回归图
- razor - 根据 URL 更改导航栏
- java - 将 .jar 文件添加到项目的问题
- azure - 自动化脚本与导出模板
- python - 检查python中数据框中的字符串是否为日期时间(mm-dd-yyyy)格式
- antd - Antd 用作数组形式的输入
我目前正在使用 ant-design UI 构建一个反应应用程序。我对表格有疑问。到目前为止,我已经能够创建和提交普通表单。但是当我试图创建一个更复杂的表单时,我遇到了这些问题:
我想用这样的输入创建一个表单:
code: string, name: string, order: { itemid: number, qty: number }
“订单”部分
- google-apps-script - 如何将列复制到另一列的第一个空白单元格?
- sql-server - 将不同表的外键插入sql server中的一张表
- google-app-engine - 使用 App Engine 模块在 F1 实例类中运行 cron 作业
- validation - 当验证不好时如何做出反应本机警报而不是错误消息