<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="./vue.js"></script>
<style>
.a {
cursor: pointer;
}
</style>
</head>
<body>
<div id="app">
<span class="a" v-for="(n ,i) in arr " @click="f1(i)">{{n}}</span>
<div>{{content}}</div>
</div>
<script>
let vm = new Vue({
el: "#app",
data: {
arr: ["选项卡1", "选项卡2", "选项卡3"],
arr1: ["内容1", "内容2", "内容3"],
content: "内容1",
},
methods: {
f1(i) {
this.content = this.arr1[i];
},
},
});
</script>
</body>
</html>
效果如下:
![](https://img2020.cnblogs.com/blog/2140136/202012/2140136-20201221223214267-2090104059.png)