gpt4 book ai didi

php - jsonEncode owl carousel 2 响应式配置如何

转载 作者:行者123 更新时间:2023-12-01 05:40:29 24 4
gpt4 key购买 nike

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'))
));

这是错误:

Uncaught TypeError: Cannot use 'in' operator to search for 'length' in { 0:{items:1,nav:true}, 768:{items:2,nav:false}, 992:{items:3,nav:true} }

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

最佳答案

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)
),

关于php - jsonEncode owl carousel 2 响应式配置如何,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31057760/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com