使用内联 if 语句禁用 swiper.js 自动播放

Disable swiper.js autoplay using inline if statement

我试图根据获取 a 值的小部件名称参数禁用滑动器自动播放。 (我使用 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 之前,它就是这样工作的