【问题标题】:How do I import Bulma Carousel in Angular 10?如何在 Angular 10 中导入 Bulma Carousel?
【发布时间】:2020-07-23 07:51:54
【问题描述】:

我正在尝试将 Bulma carousel https://github.com/wikiki/bulma-carousel 导入 Angular 10 应用程序。

  • 我已经通过 angular.json 导入了 javascript。

  • 在要显示轮播的组件中,我尝试导入类并访问它

    import {bulmaCarousel} from 'bulma-carousel';
    ...
    ngOnInit(): void {
    
    
    this.carousel = bulmaCarousel.attach('#carousel-demo', {
      slidesToScroll: 1,
      slidesToShow: 4
    });
    

我收到一条错误消息

TypeError: Cannot read property 'attach' of undefined at HomeComponent.ngOnInit (http:

如果我尝试将其随机导入 app.module

import {bulmaCarousel} from 'bulma-carousel';
...
imports [
  bulmaCarousel 

我明白了

ERROR in src/app/app.module.ts:71:12 - error NG1010: Value at position 16 in the NgModule.imports of AppModule is not a reference: [object Object]

【问题讨论】:

    标签: angular bulma


    【解决方案1】:

    似乎工作,home.component.ts:

    import {bulmaCarousel} from 'bulma-carousel']
    
    declare var bulmaCarousel: any;
    

    然后在 ngOnInit() 中加载库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-26
      相关资源
      最近更新 更多