85 lines
1.9 KiB
HTML
85 lines
1.9 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>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
list-style: none;
|
|
}
|
|
|
|
ul {
|
|
display: flex;
|
|
}
|
|
|
|
.tabs_title {
|
|
height: 45px;
|
|
align-items: center;
|
|
}
|
|
|
|
.tabs_title li {
|
|
margin: 0 10px;
|
|
}
|
|
|
|
.tabs_content li {
|
|
display: none;
|
|
}
|
|
|
|
.active_content {
|
|
display: block !important;
|
|
}
|
|
|
|
.active_title {
|
|
color: red;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="app">
|
|
|
|
<ul class="tabs_title">
|
|
<li :class="index == currentIndex ? 'active_title' : '' "
|
|
@click="changeActive(index)"
|
|
v-for="item,index in tabs">
|
|
{{ item.title }}
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
<ul class="tabs_content">
|
|
<li :class="index == currentIndex ? 'active_content' : '' "
|
|
v-for="item,index in tabs">
|
|
{{ item.content }}
|
|
</li>
|
|
</ul>
|
|
</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,
|
|
tabs: [
|
|
{ id: 1, title: '首页', content: '首页 的内容' },
|
|
{ id: 2, title: '社会', content: '社会 的内容' },
|
|
{ id: 3, title: '财经', content: '财经 的内容' },
|
|
{ id: 4, title: '体育', content: '体育 的内容' },
|
|
]
|
|
},
|
|
methods: {
|
|
changeActive(index) {
|
|
console.log(index);
|
|
this.currentIndex = index
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
|
|
</html> |