<!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>Documen</title>
</head>
<body>
<div id="app">
<!-- 图片 -->
<img v-bind:src="imgArr[index]" alt="">
<!-- 左箭头 -->
<button v-on:click="prev" v-show="index!=0">上一张</button>
<!-- 右箭头 -->
<button v-on:click="next" v-show="index<imgArr.length-1">下一张</button>
</div>
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> <br>
<script>
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!',
imgArr: ["https://cjunn.gitee.io/blog_theme_atum/style1/img/ing/ingbc.webp",
"https://pic.cnblogs.com/avatar/2210235/20201122215811.png"],
index:0
},
methods:{
prev:function(){
this.index--;
},
next:function(){
this.index++;
}
}
})
</script>
</body>
</html>