forked from tushargugnani/learningVueJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15.image-changer.html
43 lines (41 loc) · 1.56 KB
/
15.image-changer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<!-- development version, includes helpful console warnings -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body class="py-5">
<div class="container">
<div id="app" class="text-center">
<img :src="'/assets/images/'+images[currentImage]" width="400" height="500"><br/><br/>
<button @click="previousImage" class="btn btn-primary" :disabled="currentImage === 0">Previous</button>
<button @click="nextImage" class="btn btn-primary" :disabled="currentImage === (images.length - 1)">Next</button>
</div>
</div>
</div>
</body>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
images: ['cat1.jpg', 'cat2.jpeg', 'cat3.jpg', 'cat4.jpg'],
currentImage : 0
},
methods:{
nextImage: function(e){
if(this.currentImage !== (this.images.length -1))
this.currentImage++;
},
previousImage: function(e){
if(this.currentImage !== 0)
this.currentImage--;
}
}
});
</script>
</html>