简体   繁体   English

在离子菜单中实施离子载玻片不起作用

[英]Implementation of ion-slides in ion-menu not working

I am trying to implement "sliding images" in side-menu of Ionic-3. 我正试图在Ionic-3的侧面菜单中实现“滑动图像”。

Following is my code : 以下是我的代码:

<ion-menu [content]="content">
  <ion-content>
        <ion-slides>
            <ion-slide>
                <img class="slide-image" src="img1.png">
            </ion-slide>
            <ion-slide>
                <img class="slide-image" src="img2.png">
            </ion-slide>
            <ion-slide>
                <img class="slide-image" src="img3.png">
            </ion-slide>
        </ion-slides>

        <ion-list>
          <p>some menu items</p>
        </ion-list>
  </ion-content>
</ion-menu>

<ion-nav [root]="rootPage" #content></ion-nav>

The elements are rendering properly but the problem is that the <ion-slide> is behaving like horizontal scroll view in side menu. 元素正确渲染,但问题是<ion-slide>的行为类似于侧面菜单中的水平滚动视图。

I have tried to disable the swipe gesture of side-menu but still the behavior of <ion-slide> persist. 我试图禁用侧面菜单的滑动手势,但仍然存在<ion-slide>的行为。

Even I have tried to use slideNext and slidePrev method of Slides but they are not working. 即使我曾尝试使用Slides slideNextslidePrev方法,但它们无法正常工作。

Is there any way I can implement the sliding-images in side-menu either using Ionic-3 or third party library? 有没有什么办法可以使用Ionic-3或第三方库在侧边菜单中实现滑动图像?

Verifying the ion-slides in the menu, the behaviour of these is normal in the sidemenu. 验证菜单中的离子载玻片,这些在侧面菜单中的行为是正常的。 Take a look in this link. 看看这个链接。 these slides are only slides with a backgrounds of different colors. 这些幻灯片只是具有不同颜色背景的幻灯片。

the implementation is in the part of: 实施是在以下部分:

 @App({
  template: `
    <ion-menu [content]="content">

      <ion-toolbar>
        <ion-title>Pages</ion-title>
      </ion-toolbar>

      <ion-content>
        <ion-slides pager>

          <ion-slide style="background-color: green">
            <h2>Slide 1</h2>
          </ion-slide>

          <ion-slide style="background-color: blue">
            <h2>Slide 2</h2>
          </ion-slide>

          <ion-slide style="background-color: red">
            <h2>Slide 3</h2>
          </ion-slide>

        </ion-slides>
      </ion-content>

    </ion-menu>

    <ion-nav id="nav" [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>

  `
})

Making this work requires a little bit of bootstrapping in order to get the underlying Swiper library to properly initialize. 完成这项工作需要一些引导才能使底层Swiper库正确初始化。 The ion-menu starts out with display:none , so Swiper cannot properly read the size using clientWidth on the slide container. 离子菜单以display:none开头,因此clientWidth无法使用幻灯片容器上的clientWidth正确读取大小。

See my answer here for code that shows how to deal with this problem: Is it possible to use slides in ionic sidebar 有关如何处理此问题的代码,请参阅我的答案: 是否可以在离子侧栏中使用幻灯片

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

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