<!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>Document</title>
<style>
#app {
position: relative;
width: 600px;
height: 440px;
}
.left {
position: absolute;
left: 0;
top: 190px;
}
.w60 {
width: 60px;
height: 60px;
}
.right {
position: absolute;
right: 0;
top: 190px;
}
</style>
</head>
<body>
<div id="app">
<img :src="imgArr[index]" alt="">
<!-- 左箭头 -->
<a href="javascript:void(0)" class="left" @click="prev" v-show="index > 0">
<img src="./images/left-circle.png" class="w60" alt="">
</a>
<!-- 右箭头 -->
<a href="javascript:void(0)" class="right" @click="next" v-show="index < imgArr.length-1">
<img src="./images/right-circle.png" class="w60" alt="">
</a>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var app = new Vue({
el: "#app",
data: {
imgArr: [
"./images/00.jpg",
"./images/01.jpg",
"./images/02.jpg",
"./images/03.jpg",
"./images/04.jpg",
],
index: 0
},
methods: {
prev: function () {
this.index--;
},
next: function () {
this.index++;
}
}
})
</script>
</body>
</html>
05-06
1171
09-27
8231
08-15