小编use*_*842的帖子

Bootstrap 轮播不适用于 Angular6

我正在使用带有 angular6 的 bootstrap4 轮播,但出现以下错误。由于我使用 bootstrap,所以我也必须使用 jQuery。我已经通过 npm 安装了 bootsrap、jquery 模块。我在 stackoverflow 上检查了很多步骤,但没有帮助。控制台中的错误是AppComponent.html:4 ERROR TypeError: jquery__WEBPACK_IMPORTED_MODULE_1__(...).carousel is not a function

ERROR in src/app/header/header.component.ts(17,20): error TS2339: Property 'carousel' does not exist on type 'JQuery<HTMLElement>'.
Run Code Online (Sandbox Code Playgroud)

MyComponent.ts 文件:

import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';
@Component({
   selector: 'app-header',
   templateUrl: './header.component.html',
   styleUrls: ['./header.component.css']
})

export class HeaderComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

  ngAfterViewInit() {
    $('.carousel').carousel();
  }
}
Run Code Online (Sandbox Code Playgroud)

下面是 HTML 代码:

    <div class="bd-example">
  <div …
Run Code Online (Sandbox Code Playgroud)

carousel bootstrap-4 angular angular6

2
推荐指数
1
解决办法
7004
查看次数

标签 统计

angular ×1

angular6 ×1

bootstrap-4 ×1

carousel ×1