83 lines
1.8 KiB
HTML
83 lines
1.8 KiB
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>
|
|
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
<style>
|
|
ul,
|
|
.title {
|
|
list-style: none;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
.title {
|
|
overflow: hidden;
|
|
}
|
|
|
|
.title p {
|
|
float: left;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.active {
|
|
color: red;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="app">
|
|
|
|
|
|
<div class="title">
|
|
<p v-for="item,index in tabs" :key="index" :class="index == ActiveIndex ? 'active' : '' "
|
|
@click="changeTabs(index)">
|
|
{{ item.title }}
|
|
</p>
|
|
</div>
|
|
|
|
<div class="content" v-show="index == ActiveIndex" v-for="z,index in tabs.length">
|
|
<p v-for="v,i in tabs[ActiveIndex].content">{{v.nr}}</p>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</body>
|
|
|
|
<script>
|
|
new Vue({
|
|
el: '.app',
|
|
data: {
|
|
ActiveIndex: 0,
|
|
tabs: [
|
|
{
|
|
id: 1, title: '热门', content: [
|
|
{ id: 1, nr: '333' },
|
|
{ id: 2, nr: '33' },
|
|
{ id: 3, nr: '44' },
|
|
]
|
|
},
|
|
{
|
|
id: 2, title: '推荐', content: [
|
|
{ id: 1, nr: 'dd' },
|
|
{ id: 2, nr: 'cc' },
|
|
{ id: 3, nr: '222' },
|
|
]
|
|
}
|
|
]
|
|
},
|
|
methods: {
|
|
changeTabs(ix) {
|
|
this.ActiveIndex = ix;
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
|
|
</html> |