【问题标题】:Disable swiper.js autoplay using inline if statement使用内联 if 语句禁用 swiper.js 自动播放
【发布时间】:2021-06-29 09:49:34
【问题描述】:

我正在尝试根据获取我 a 值的小部件名称参数来禁用 swiper 自动播放。 (我使用 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

【问题讨论】:

    标签: php magento swiper


    【解决方案1】:
    <?= ($block->getData(‘autoplay’) == "1") ?'{  delay: 2500,  disableOnInteraction: false,  }':'false'?>,
    

    解决方案是将属于 autoplay == 1 的代码包装在 '' 中,并且在 : 为 false 之前,它可以这样工作

    【讨论】:

      猜你喜欢
      • 2022-11-25
      • 2017-10-28
      • 1970-01-01
      • 1970-01-01
      • 2019-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多