gpt4 book ai didi

Angular 9 : ngx-owl-carouel not rendered because of "Cannot read property ' $owl' of undefined"error

转载 作者:行者123 更新时间:2023-12-04 16:27:19 24 4
gpt4 key购买 nike

我正在尝试在我的项目中实现卡片 slider 。实际上,我无法弄清楚为什么 ngx-owl-carousel 没有被渲染并给出一个烦人的问题。我一步一步按照npm上的指南进行操作。并尝试在 Angular Docs 上放入 Card 示例.

<owl-carousel
[options]="{items: 3, dots: false, navigation: false}" [items]="professionals"
[carouselClasses]="['owl-theme', 'row', 'sliding']">
<div class="item" *ngFor="let professional of professionals;let i = index">
<mat-card class="example-card">
<mat-card-header>
<div mat-card-avatar class="example-header-image"></div>
<mat-card-title>Shiba Inu</mat-card-title>
<mat-card-subtitle>Dog Breed</mat-card-subtitle>
</mat-card-header>
<img mat-card-image src="https://material.angular.io/assets/img/examples/shiba2.jpg"
alt="Photo of a Shiba Inu">
<mat-card-content>
<p>
The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog from Japan.
A small, agile dog that copes very well with mountainous terrain, the Shiba Inu was originally
bred for hunting.
</p>
</mat-card-content>
<mat-card-actions>
<button mat-button>LIKE</button>
<button mat-button>SHARE</button>
</mat-card-actions>
</mat-card>
</div>
</owl-carousel>

我还正确导入了 JQuery 和 NGX Carousel(样式表也是):

"styles": [
"src/styles.scss",
"./node_modules/owl.carousel/dist/assets/owl.carousel.css",
"./node_modules/owl.carousel/dist/assets/owl.theme.default.css"
],
"scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/owl.carousel/dist/owl.carousel.js"
]

但是在浏览器中它不断抛出这个错误(即使里面没有任何对象)。

Browser Console Error

最佳答案

owl-carousel 标签中删除 [items]="professionals。仅当图像数组动态变化时才需要它。

关于 Angular 9 : ngx-owl-carouel not rendered because of "Cannot read property ' $owl' of undefined"error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60941547/

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