首页 > 解决方案 > Owl Carousel 2 不适用于 Angular 5

问题描述

我需要将 OwlCarousel2 与 Angular5 一起使用,并且我正在使用https://www.npmjs.com/package/ngx-owl-carousel但其显示错误请参见下图以供参考。任何帮助,将不胜感激。

在此处输入图像描述

标签: angular5owl-carousel-2

解决方案


从您的屏幕截图来看,这不是猫头鹰轮播问题。它发生在您的应用程序组件文件中未包含 jquery。

所以使用以下命令安装

npm install jquery — save

在 .angular.json 文件中添加 jquery 文件

“scripts”: [ “../node_modules/jquery/dist/jquery.min.js” ]

然后在 app.component.ts 文件中按如下方式导入。

import * as $ from ‘jquery’;

那么现在你可以使用errors了。

笔记:-

如果你想在你的应用程序中使用 bootstrap,或者如果你已经在你的项目中使用了,请确保在包含 bootstrap javascript 文件之前包含 jQuery,如下所示。由于 bootstrap 的 javascript 文件需要 jQuery。

“scripts”: [ “../node_modules/jquery/dist/jquery.min.js”,
“../node_modules/bootstrap/dist/js/bootstrap.js”]

参考链接:- https://googleweblight.com/i?u=https://medium.com/@swarnakishore/how-to-include-and-use-jquery-in-angular-cli-project-592e0fe63176&hl=en -在

https://googleweblight.com/i?u=https://stackoverflow.com/questions/43934727/how-to-use-jquery-plugin-with-angular-4&hl=en-IN

这是两个链接,提供了在您的应用程序中导入 jquery 的一些想法。

请尝试一次并告诉我。

我希望它能解决你的问题。


推荐阅读