选项卡代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>选项卡</title>
<style>
* {
margin: 0;
padding: 0;
list-style: none;
}
.itany {
width: 600px;
margin: 30px auto;
}
.ul1 {
width: 600px;
overflow: hidden;
}
.ul1 li {
width: 198px;
background: orange;
float: left;
text-align: center;
line-height: 50px;
color: white;
border: 1px solid white;
}
.ul2 li{
width: 600px;
height: 300px;
color: white;
text-align: center;
line-height: 300px;
background:pink;
}
</style>
</head>
<body>
<div class="itany">
<ul class="ul1">
<li v-for="(value,index) in arr" @click="btn(index)">{{value.li1}}</li>
</ul>
<ul class="ul2">
<li v-for="(value,index) in arr" v-show="value.see"> {{value.li2}}</li>
</ul>
</div>
<script src="../vue.js"></script>
<script>
new Vue({
el: '.itany'
, data: {
arr: [
{li1:'选项卡1',li2:'1111111111',see:true},
{li1:'选项卡2',li2:'2222222222',see:false},
{li1:'选项卡3',li2:'3333333333',see:false}
],
}
, methods: {
btn: function(ind) {
for(var i=0;i<this.arr.length;i++){
this.arr[i].see=false;
}
this.arr[ind].see=true;
}
}
})
</script>
</body>
</html>
网友评论