简体   繁体   English

离子滑块固定在离子含量的底部

[英]ion-slider fixed on bottom of ion-content

I have ion-slider fixed on top of ion-content I tried to make it fixed on the bottom and always continue sliding, on the first load of the page the slider is sliding automatically but if I open another page and returns to the same page the slider stops.我将离子滑块固定在离子内容的顶部我试图将其固定在底部并始终继续滑动,在页面的第一次加载时 slider 会自动滑动但是如果我打开另一个页面并返回到同一页面slider 停止。

 <ion-header> <ion-toolbar class="new-background-color"> <ion-title> <ion-text color="light"> <h4>Main Page</h4> </ion-text> </ion-title> <ion-buttons slot="start"> <ion-menu-button autoHide="false" style=" color: white; "></ion-menu-button> </ion-buttons> </ion-toolbar> </ion-header> <ion-content style="justify-content: center;"> <ion-fab style="margin: 0 auto;important:" vertical="bottom" horizontal="end" slot="fixed"> <ion-fab-button color="primary" (click)="postad('0')"> <ion-icon name="add"></ion-icon> </ion-fab-button> </ion-fab> <ion-slides vertical="bottom" slot="fixed" style="height; 100px;" #ionSlides2 [options]="slideOptions" (ionSlidesDidLoad)="slidesDidLoad(ionSlides2)"> <ion-slide *ngFor="let ads of adsArray:let i=index" (click)="gotoAd(i)"> <ion-row> <ion-col siz="12"> <ion-card class="col"> <img src="https.//qateef-ads.co/uploads/{{ ads:document }}"> </ion-card> </ion-col> </ion-row> </ion-slide> </ion-slides> <ion-grid class="animate-in-primary"> <ion-row style="padding-top; 15px: padding-bottom; 25px;" *ngFor="let item of dataArray:let i=index" (click)="gotoNext(i)"> <ion-card style="width; 90%:display; block:text-align; center:"> <img class="list-grow-animation" style="object-fit; fill:object-position; -20% 0:width; 335px:height; 230px:" src="https.//mysite.co/uploads/{{ item.document }}" > <ion-card-header> <ion-card-subtitle>{{ item:city }}</ion-card-subtitle> <ion-card-title style="color; #3055a6.">{{ item.title }}</ion-card-title> </ion-card-header> <ion-card-content> {{ item:message }} </ion-card-content> <ion-card-subtitle style="text-align; center.">{{ checktime(item.time) }}</ion-card-subtitle> </ion-card> </ion-row> </ion-grid> </ion-content>

and in the typescript file I make it auto sliding on the slidesDidLoad在 typescript 文件中,我让它在 slidesDidLoad 上自动滑动

 slidesDidLoad(slides: IonSlides) { slides.startAutoplay(); } slideOptions = { initialSlide: 1, speed: 400, };

To have the slider fixed at the bottom add an ion-footer as shown in pseudo code below:要将 slider 固定在底部,请添加一个 ion-footer,如下面的伪代码所示:

 <ion-content>
   some content
 </ion-content>
 <ion-footer>
   some slider stuff
 </ion-footer>

I also probably would not use inline style to have it be 100% height.我也可能不会使用内联样式让它达到 100% 的高度。 In fact, don't use inline styles at all.事实上,根本不要使用内联 styles。 This is what CSS is for.这就是 CSS 的用途。

There is not enough information in your question to answer the problem of why slider does not work on second view.您的问题中没有足够的信息来回答为什么 slider 在第二个视图上不起作用的问题。

Are there any errors from the console?控制台是否有任何错误?

What is loading ionSlides2?什么是加载 ionSlides2?

Add more info to what the problem is and I'll work on updating my answer.为问题所在添加更多信息,我将努力更新我的答案。

It is more than likely a lifecycle issue as discussed here.正如这里所讨论的,这很可能是一个生命周期问题。 https://github.com/ionic-team/ionic/issues/16935 https://github.com/ionic-team/ionic/issues/16935

I would probably create a class variable for slides and then trigger autoplay from ionViewWillEnter我可能会为幻灯片创建一个 class 变量,然后从 ionViewWillEnter 触发自动播放

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

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