php - 使用内联 if 语句禁用 swiper.js 自动播放
问题描述
我试图根据一个小部件名称参数来禁用刷卡器自动播放,这让我得到了一个值。(我使用 magento 小部件,我从 widget.xml 中获取值)这是一个示例:
simulateTouch: <?= ($block->getData('is_gestures') == "1") ?'true':'false'?>,
// ---- gestures end -----
freeMode: true,
// --- infinite loop -----
loop: <?= ($block->getData('infiniteLoop') == "1") ?'true':'false'?>,
// --- autoplay ----
autoplay: {
delay: 2500,
disableOnInteraction: false,
},
使用其他值很容易,因为它是假的,但在这种情况下,如果我的 $block->getData('autoplay') == "1" 我需要显示该代码,但我不知道该怎么做我试过
<?= ($block->getData(‘autoplay’) == "1") ?{ delay: 2500, disableOnInteraction: false, },:''?>, or with the code inside '' but it bugs my swiper all the time
解决方案
<?= ($block->getData(‘autoplay’) == "1") ?'{ delay: 2500, disableOnInteraction: false, }':'false'?>,
解决方案是将属于 autoplay == 1 的代码包装在 '' 中,并且在 : 为 false 之前,它以这种方式工作
推荐阅读
- java - 如何在不同的图像视图中设置不同的裁剪图像
- python - 匹配目录中的部分名称
- javascript - 在 angular 中出现打字稿错误,无法正确绑定
- c# - 使用类字段作为参数时抛出 ArgumentOutOfRangeException 时出现 CA2208
- php - all() 函数 Laravel 中的每个都没有数据
- azure - 发生 AZURE SQL 插入时如何触发逻辑应用
- javascript - 如何将数组中的项目数组解析为浮点/整数
- java - 有什么方法可以在 IntelliJ 中获得类似 Eclipse 的自动完成功能?
- xamarin.forms - ReadOnlyObservableCollection 显示重复值
- python - 为什么管道被用作 GridsearchCV 的一部分而不是相反?