javascript - 动态滑动器只能在第一张幻灯片上显示和循环
问题描述
动态滑块能够从数据库中获取所有数据,但只能在第一个滑块上显示所有数据。而不是随后在滑块中显示。抱歉这个愚蠢的问题,已经为此工作了数周,但似乎找不到任何解决方案。php中的while循环应该不是问题,但我可能错了。任何人都可以请赐教吗?
PHP
<?php
$connect = mysqli_connect("localhost", "root", "", "db");
$result = make_query($connect);
function fetch_array(&$array) {
// Grab the first value from the array
$return = current($array);
// remove the value we just grabbed
array_shift($array);
// if what we have is an array spit it out, else return false
return is_array($return) ? $return : false;
}
function make_query($connect) {
$query = "SELECT * FROM db.slider ORDER BY p_id ASC";
$result = mysqli_query($connect, $query);
return $result;
}
function make_slides($result) {
$output = '';
$count = 0;
while($row = mysqli_fetch_assoc($result)) {
// while($row = fetch_array($result)) {
// Not needed as the output is the same
//if($count == 0) {
$output .= '
<div class="swiper-slide platform">
<img src="'.$row["p_img"].'" alt="'.$row["p_name"].'" />
<div class="swiper-slide platform">
<h3>'.$row["p_desc"].'</h3>
</div>
</div>';
// Not used at the moment
$count++;
//echo json_encode($row);
echo $output;
}
return $output;
}
JS 扫地机
<script>
var swiper = new Swiper('.swiper-container.platform', {
effect: 'coverflow',
initialSlide: 0-5,
grabCursor: true,
centeredSlides: true,
slidesPerView: 'auto',
coverflowEffect: {
rotate: 0,
stretch: 0,
depth: 800,
modifier: 1,
slideShadows: true,
},
pagination: {
el: '.swiper-pagination',
}
});
</script>
解决方案
设法通过使用另一个滑块/滑动器解决了这个问题。
推荐阅读
- python - 如何使用 DateTIme 索引此数据集?
- c++ - 如何捕获点云并将它们保存到 PCD 文件中
- javascript - 悬停时 Highchart 的饼图不透明度变化
- blockchain - 简单的solidity误解——它如何/在哪里利用区块链?
- elasticsearch - 嵌套类型而不引用 Mongoosastic 中的另一个模式
- javascript - Persist dropzone files in Session storage
- c - 在 X86 计算机 (Ubuntu 16.04) 上交叉编译后执行文件无法执行并移动到 arm 板 (odroid, Ubuntu Mate 18.04)
- c# - 从另一个类调用静态函数时如何修复“不存在”?
- flask - 多对多 - 基于额外关联字段的关联对象查询
- gps - 在某些车型上,连接 CarPlay 的 CLLocation 速度高于未连接 CarPlay 的速度