BootStrap 5.0样式未在Angular中渲染



我正试图在Angular项目中使用BootStrap,并能够在项目的索引文件中使用以下内容在前端呈现样式:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">

到目前为止还不错,但我试图按照这个链接来渲染样式,而不在索引文件BootStrap中引用Angular。因此在angular.json文件中添加了以下行:

"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
]

我相信,这是以前的链接。我不确定我是否错过了什么?我所做的是以下内容,并且没有呈现按钮样式:

<button type="button" class="btn btn-primary">Add</button> //Though the class name doesn't show while writing 

您必须禁用封装

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class AppComponent {}

最新更新