Javascript 在angular中找不到CSS

Javascript 在angular中找不到CSS,javascript,html,css,angular,Javascript,Html,Css,Angular,我已经使用cli生成了一个组件 "ng generate component registration" 它创建了以下文件 registration.component.html registration.component.scss registration.component.spec.ts registration.component.ts 现在,我已经在scss文件中添加了一个css类 .loginBox { width: 260px; } 现在在html文件中 <p cl

我已经使用cli生成了一个组件

"ng generate component registration"
它创建了以下文件

registration.component.html
registration.component.scss
registration.component.spec.ts
registration.component.ts
现在,我已经在scss文件中添加了一个css类

.loginBox {
 width: 260px;
}
现在在html文件中

<p class="loginBox"> test </p>
registration.component.scss

.loginBox {
  /* color: #4C4633; */
  /* font-size: 12px; */
  /* margin-bottom: 10px; */
  /* padding: 10px 0px 10px 10px; */
  width: 260px;
}
registration.component.html

<p class="loginBox">
  registration works!
</p>
<div class="loginBox"> test </div>
<div class="container-fluid p-0">
  <router-outlet></router-outlet>
</div>

看这个。在@component定义中使用
封装:查看封装。无

参见此。在@component定义中使用
封装:查看封装。无

SCS是否正确读取?尝试运行此命令

ng config schematics。@schematics/angular:component.styleext-scss


然后,重新运行项目

是否正确读取了SCS?尝试运行此命令

ng config schematics。@schematics/angular:component.styleext-scss

然后,重新运行项目

尝试:

:主机::ng deep{
.loginBox{
宽度:260px;
}
}
试试:

:主机::ng deep{
.loginBox{
宽度:260px;
}
}

您是否构建了项目的css<代码>SCS
文件通常不会在生产中加载;它们需要被构建到一个
css
文件中?在我做了一个构建之后它就不工作了。我们能看到实际的错误吗?没有错误。这正是IDE所指出的此行有多个标记-未定义的CSS类(loginBox)。-1更改行“您是否可以共享组件的ts文件以检查是否存在任何小错误?您是否构建了项目的css<代码>SCS
文件通常不会在生产中加载;它们需要被构建到一个
css
文件中?在我做了一个构建之后它就不工作了。我们能看到实际的错误吗?没有错误。这正是IDE所指出的此行有多个标记-未定义的CSS类(loginBox)。-1更改行“您是否可以共享组件的ts文件以检查是否有任何小错误?我的Angular.json`“schematics”:{“@schematics/Angular:component”:{“styleext”:“scss”}`我的Angular.json`“schematics”:{“@schematics/Angular:component”:{“STYLEXT”:“scss”}}`你能给你的答案增加一点上下文吗?这应该解决什么问题和/或你为什么推荐它?你能给你的答案增加一点上下文吗?这应该解决什么问题和/或你为什么推荐它?
<div class="container-fluid p-0">
  <router-outlet></router-outlet>
</div>
const routes: Routes = [
  { path: '', component: RegistrationComponent}
];
@NgModule({
  declarations: [RegistrationComponent],
imports: [
    BrowserModule,
    RouterModule.forRoot(routes)
  ],
  providers: [PreviousUrlService, {provide: APP_BASE_HREF, useValue : '/' }],
  bootstrap: [AppComponent]
})
export class AppModule { }