2017-09-26 36 views
2

我在主页上有Ionic3 App和离子幻灯片组件。Ionic 3 - ion-slide inline css

<ion-slides pager> 
    <ion-slide *ngFor="let blog of blogs | async" > 
     <h2>{{ blog.title }}</h2> 
     <p> 
     <a target="_blank" class="slider-read-more" ion-button outline color="secondary" (click)="blogDetail(blog)">ვრცლად</a> 
     </p> 
    </ion-slide> 
    </ion-slides> 

我想用风格

<ion-slide *ngFor="let blog of blogs | async" style="background:url(blog.image) no-repeat center center fixed;"> 

添加内嵌CSS背景图像,但无法通过内部blog.image。这个怎么做?

回答

3

您可以尝试如下图所示:

即使用backgroundImage作为一个属性绑定:

<ion-slide [style.backgroundImage]="'url(' + blog.image + ')'"> ... 
+0

{{blog.image}}不能在这里工作。 –

+1

我已经编辑了答案,可以请现在试试@GochaGochitashvili? – sebaferreras

+2

是的,作品!谢谢。 –