【发布时间】:2018-12-09 12:24:55
【问题描述】:
我在 Angular 7 中使用 Owl 轮播。 首先,我使用
安装 npm install ngx-owl-carousel owl.carousel jquery --save
然后添加
"scripts": ["./node_modules/jquery/dist/jquery.min.js",
"./node_modules/owl.carousel/dist/owl.carousel.min.js"]
在 angular.json 文件中 并添加
import { OwlModule } from 'ngx-owl-carousel';
imports: [
BrowserModule,
OwlModule
]
在 app.module.ts 文件中 然后我用了
public ngOnInit()
{
/*----------------------------
Slideshow
------------------------------ */
$('.slideshow').owlCarousel({
items: 6,
autoPlay: 3000,
singleItem: true,
navigation: true,
navigationText: ['<i class="fa fa-chevron-left"></i>', '<i class="fa fa-chevron-right"></i>'],
pagination: true
});
}
在 app.component.ts 文件中,但我有错误
core.js:14576 ERROR TypeError: jquery__WEBPACK_IMPORTED_MODULE_2__(...).owlCarousel 不是函数
我错在哪里?请帮我。 谢谢。
【问题讨论】:
-
您可以将此版本用于 Angular 7:ngx-owl-carousel-o
标签: angular owl-carousel