97 lines
2.4 KiB
HTML
97 lines
2.4 KiB
HTML
<!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>Document</title>
|
|
<style>
|
|
ul,li {
|
|
margin: 0;
|
|
padding: 0;
|
|
list-style: none;
|
|
}
|
|
.tabs_title {
|
|
display: flex;
|
|
}
|
|
|
|
.tabs_title li {
|
|
margin-right: 10px;
|
|
}
|
|
.tabs_title_active {
|
|
color: red;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="app">
|
|
<ul class="tabs_title">
|
|
<li :class=" index == currentIndex ? 'tabs_title_active' : '' "
|
|
@click="currentIndex = index"
|
|
v-for="(item,index) in tabsList">
|
|
{{ item.title }}
|
|
</li>
|
|
</ul>
|
|
|
|
<div class="tabs_conetnt">
|
|
|
|
<div class="" v-for="(item,index) in tabsList">
|
|
<div v-if="index == currentIndex">
|
|
<p v-for="(v,i) in item.content">{{ v.text }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
|
|
<script>
|
|
new Vue({
|
|
el: '.app',
|
|
data: {
|
|
currentIndex: 0,
|
|
tabsList: [
|
|
{
|
|
id: 1,
|
|
title: '社会',
|
|
content: [
|
|
{ text: '社会的内容1' },
|
|
{ text: '社会的内容2' },
|
|
{ text: '社会的内容3' },
|
|
]
|
|
},
|
|
{
|
|
id: 2,
|
|
title: '军事',
|
|
content: [
|
|
{ text: '军事的内容1' },
|
|
{ text: '军事的内容2' },
|
|
{ text: '军事的内容3' },
|
|
]
|
|
},
|
|
{
|
|
id: 3,
|
|
title: '体育',
|
|
content: [
|
|
{ text: '体育的内容1' },
|
|
{ text: '体育的内容2' },
|
|
{ text: '体育的内容3' },
|
|
]
|
|
},
|
|
]
|
|
},
|
|
created() {
|
|
|
|
},
|
|
methods: {
|
|
changeTitle(i) {
|
|
this.currentIndex = i
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
|
|
</html> |