html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<!-- 图片路径使用模板字符串 -->
<img :src=`./image${number}.png` style="width: 300px;height: 300px;">
<hr>
<button @click="number=number-1;if(number<1){number=3}">上一张图片</button>
<span>当前图片编号:{{number}}</span>
<button @click="number=number+1;if(number>3){number=1}">下一张图片</button>
<!-- 第二种思路 -->
<hr>
<ul>
<li v-for="value in 3">
<a href="#" @click="number=value">{{value}}</a>
</li>
</ul>
</div>
<script type="module">
import { createApp, reactive, ref, watchEffect } from './vue.esm-browser.js'
createApp({
setup() {
const number=ref(1)
return {
number
}
}
}).mount("#app")
</script>
</body>
</html>