繁体   English   中英

Owl Carousel在Angular 4中不起作用

[英]Owl Carousel is not working in Angular 4

我正在开发angular 4,我想在我的应用程序中实现owl carousel。 我通过此链接https://www.npmjs.com/package/ng2-owl-carousel引用了应用程序中的猫头鹰轮播。

但是图像还没有到来。 我正在分享我的代码:

home.component.ts

import { Component } from '@angular/core';
import {Http} from '@angular/http';
import {OwlCarousel} from 'ng2-owl-carousel';
import { ViewChild } from '@angular/core'
declare var $:any;
@Component({
    moduleId:module.id,
    templateUrl:'home.component.html'
})

export class HomeComponent{
    public pageTitle:string ='Home';
    @ViewChild('owlElement') owlElement: OwlCarousel       

      fun() {
        this.owlElement.next([200])
        //duration 200ms
      }
      object = {          
        link: "http://lorempixel.com/100/100"
      }

}

home.component.html

<owl-carousel
[options]="{items: 3, dots: false, navigation: false}"

[items]="images"

[carouselClasses]="['owl-theme', 'row', 'sliding']">
<div class="item" *ngFor="let image of images;let i = index">
    <div class="thumbnail-image" [ng-style]="{'background-image':'url(/assets/img/images.jpg)'}"></div>
</div>
</owl-carousel>

app.module.ts

imports: [
    BrowserModule,
    HttpModule,
    FormsModule,
    OwlModule
]

在此处输入图片说明 只有下一个或上一个会出现,但图像不会出现。 我是angular 4的新手。所以我无法解决此问题。 我看到了链接,但仍然无法解决。

angularjs ng-style:背景图像不起作用
Angular 2-使用ngStyle将背景图像转换为html文件

我在循环中看不到任何图像,请在ngFor中添加img:

       <img src="{{image}}" style="" />

和使用

      [ngStyle] and not [ng-style]

您是否包含了此处给出的css和js

"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/owl.carousel/dist/owl.carousel.js"

]

"styles": [ "../node_modules/owl.carousel/dist/assets/owl.carousel.css", "../node_modules/owl.carousel/dist/assets/owl.theme.default.css" ]

2]请勿使用背景图片,如下所示:

`

  1. 可能是图片网址路径[ng-style] =“ {'background-image':'url(/assets/img/images.jpg)'}”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM