<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>轮播图</title>
<link rel="stylesheet" href="./index.css"> <!-- 引入所需要css样式 -->
</head>
<body>
<div id="swiper-list"></div> <!-- 引入轮播图dom -->
</body>
<script src="./slider.js"></script> <!-- 引入所需要js -->
<script src="./index.js"></script>
</html>
// index.js
let imgArr = [
{
url: '#1.png',
imgPath: './imgs/1.png'
},
{
url: '#2.png',
imgPath: './imgs/2.png'
},
{
url: '#3.png',
imgPath: './imgs/3.png'
},
{
url: '#4.png',
imgPath: './imgs/4.png'
}
];
new Swiper({
imgArr: imgArr,
animationTime: 1000,
intervalTime: 1000,
autoplay: true
}).init();