【问题标题】:How do jsonEncode owl carousel 2 responsive config如何jsonEncode owl carousel 2 responsive config
【发布时间】:2015-06-25 18:13:30
【问题描述】:
case 'carousel':
return $helper->jsonEncode(array(
    'dots'                  => (bool) $this->getData('paging'),
    'autoPlay'              => is_numeric($this->getData('autoplay')) ? true : false,
    'autoplayTimeout'       => is_numeric($this->getData('autoplay')) ? (int) $this->getData('autoplay') : false,
    'autoplayHoverPause'    => true,
    'loop'                  => true,
    'lazyLoad'              => true,
    'responsive'            => '{
        0:{items:1,nav:true},
        768:{items:2,nav:false},
        992:{items:3,nav:true}
    }',
    'nav'                   => (bool) $this->getData('navigation'),
    'navText'               => array($this->getData('navigation_prev'), $this->getData('navigation_next'))
));

这是错误:

未捕获的类型错误:无法使用“in”运算符在 { 中搜索“长度” 0:{items:1,nav:true}, 768:{项目:2,导航:假}, 992:{项目:3,导航:真} }

如何解决这个问题?谢谢。

【问题讨论】:

  • 请编辑以标记语言。
  • 这不是 PHP 错误,听起来更像 jquery,请显示该代码

标签: php jquery owl-carousel-2


【解决方案1】:

json_encode() 与数组一起使用,您不应传递 JSON 字符串

改变:

 'responsive'            => '{
        0:{items:1,nav:true},
        768:{items:2,nav:false},
        992:{items:3,nav:true}
    }',

到:

 'responsive'=> array(
        0=>array('items'=>1,'nav'=>true),
        768=>array('items'=>2,'nav'=>false),
        992=>array('items'=>3,'nav'=>true)
    ),

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-01
    • 2020-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-14
    相关资源
    最近更新 更多