html - 单击引导卡内的 swiper.js 图像下一个/上一个按钮时如何停止传播
问题描述
我在下面这样的引导卡中使用ngx-swiper-wrapper,顶部有一个 routerlink。因此,如果我单击卡上的任何位置,它将路由。工作正常!但是,如果我在任何滑动图像上滑动/单击左/右,我想停止路由传播。我可以捕捉到事件,但似乎无法弄清楚如何停止事件方法内的传播。
任何帮助,将不胜感激。一个问题是'onIndexChange()',$event 只是索引号,所以我不能从那个开始工作,与 onSwiperEvent() 一样,我传入的 $event 是一个空数组。
仅供参考 - 我在下面都试过了,但都没有运气。都没有停止路由
preventClicksPropagation: true,
touchMoveStopPropagation: true
<div class="card" [routerLink]="['/events', event.id]">
<swiper [config]="eventsSwiperConfig" [(index)]="index" (indexChange)="onIndexChange($event)" (swiperTransitionStart)="onSwiperEvent($event)"></swiper>
<ng-container *ngFor="let photo of event.photoUrl">
<div class="outer-img-container">
<div class="img-container">
<img class="card-img swiper-lazy" src="{{photo}}">
<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>
</div>
</div>
</ng-container>
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
解决方案
我还没有找到解决方案,但我做了一个解决方法。
我将 routerlinks 放在不同的 div 上(不是最上面的 div - 引导卡)。
所以我仍然得到相同的结果,现在卡中只有 3 个不同的路由器链接,而不是顶部的 1 个
推荐阅读
- wordpress - 如何阻止对 Digital Ocean Ubuntu 的 XML-RPC 攻击
- c# - 使用 HttpClient 发布并读取 HttpResponseMessage 状态
- java - 单独的java文件中的Arraylist既不是活动也不是片段,如何从string.xml中获取字符串值?
- php - 创建登录表单错误消息 (php,css,html)
- json - JSON 阅读器 Kotlin
- azure - 在 Azure 中从 VHD 创建经典 VM
- python-2.7 - 如何让等待循环,直到硒等待按钮被按下?
- c++ - 为什么在函数声明中允许使用 const?
- html - HTML 垂直滚动条仅在水平滚动条位于右侧时可见
- ios - 如何从 Swift 4.2 上的地图(对象)Cloud Firestore 文档中获取数据?