59 lines
1.4 KiB
HTML
59 lines
1.4 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,li {
|
|
list-style: none;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
ul {
|
|
overflow: hidden;
|
|
}
|
|
li {
|
|
float: left;
|
|
margin-right: 10px;
|
|
}
|
|
.active {
|
|
color: red;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="app">
|
|
<ul>
|
|
<li v-for="item,index in tabs"
|
|
:class="index == ActiveIndex ? 'active' : '' "
|
|
@click="changeTabs(index)"
|
|
:key="index">
|
|
{{ item.title }}
|
|
</li>
|
|
</ul>
|
|
<div class="div">{{ tabs[ActiveIndex].content }}</div>
|
|
</div>
|
|
</body>
|
|
|
|
<script>
|
|
new Vue({
|
|
el: '.app',
|
|
data: {
|
|
ActiveIndex: 0,
|
|
tabs: [
|
|
{ id: 1, title: '热门', content: '热门内容' },
|
|
{ id: 2, title: '推荐', content: '推荐内容' },
|
|
{ id: 3, title: '军事', content: '军事内容' },
|
|
{ id: 4, title: '社会', content: '社会内容' },
|
|
]
|
|
},
|
|
methods: {
|
|
changeTabs(ix) {
|
|
this.ActiveIndex = ix;
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
</html> |