gpt4 book ai didi

angular - Angular 4 中的 Bootstrap 轮播错误

转载 作者:行者123 更新时间:2023-12-04 13:22:06 25 4
gpt4 key购买 nike

我在控制台中遇到错误,无法让它工作。我目前正在使用 Angular 4 和 Bootstrap。

我的前端开发人员这个周末不在,所以无法理解/查找是否有任何其他文件可以添加依赖项。我所知道的事实是;为了缩减首页大小,首页没有添加bootstrap JS函数。

这是第一行的错误:

Uncaught Error: Template parse errors:
'ngb-carousel' is not a known element:
1. If 'ngb-carousel' is an Angular component, then verify that it is part of this module.
2. If 'ngb-carousel' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

这是我的 home.component.ts:

import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { LocalStorageService } from 'angular-2-local-storage';
import { NgbCarouselConfig } from '@ng-bootstrap/ng-bootstrap';

import { AuthService } from '../../core/services/auth.service';

@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css'],
providers: [NgbCarouselConfig]
})
export class HomeComponent {
title = 'Resume - Homepage';
constructor(
private authService: AuthService,
private router: Router,
public localStorageService: LocalStorageService,
config: NgbCarouselConfig,
) {
config.interval = 5000;
config.wrap = true;
config.keyboard = false;
}
}

虽然我的 HTML:

<ngb-carousel>
<ng-template ngbSlide>
<div class="carousel-caption">
<h3>First slide label</h3>
<p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
</div>
<img src="../../../assets/img/daddy.jpg"/>
</ng-template>
<ng-template ngbSlide>
<div class="carousel-caption">
<h3>Second slide label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<img src="../../../assets/img/daddy.jpg"/>
</ng-template>
</ngb-carousel>

最佳答案

您是否在 app.module 中添加了 NgbModule

在 app.module 文件导入中应该是这样的:

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

关于angular - Angular 4 中的 Bootstrap 轮播错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49820557/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com