67 lines
1.3 KiB
HTML
67 lines
1.3 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>动态导航</title>
|
|
<style>
|
|
*{
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
#nav{
|
|
text-align: center;
|
|
width: 100%;
|
|
margin-top: 20px;
|
|
}
|
|
div{
|
|
width: 100px;
|
|
height: 50px;
|
|
display: inline-block;
|
|
}
|
|
.item{
|
|
background-color: blueviolet;
|
|
line-height:50px ;
|
|
font-size: 18px;
|
|
|
|
font-weight: bolder;
|
|
border-radius: 10px;
|
|
margin: 0 10px;
|
|
}
|
|
.active{
|
|
background-color: skyblue;
|
|
}
|
|
[v-cloak]{
|
|
display: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="nav" v-cloak>
|
|
<div :class="contents(index)" @click="change(index)" v-for="(items,index) in content" class="item">{{items}}</div>
|
|
</div>
|
|
</body>
|
|
<script src="../00-tools/JavaScript/vue.js"></script>
|
|
<script>
|
|
let vue=new Vue({
|
|
el:"#nav",
|
|
data:{
|
|
content:["首页","搜索","人文","新闻","法制","联系我们"],
|
|
isActive:true,
|
|
courseindex:-1,
|
|
},
|
|
methods: {
|
|
change:function(index){
|
|
this.courseindex=index
|
|
},
|
|
contents:function(index){
|
|
if(index==this.courseindex){
|
|
return {active:this.isActive}
|
|
}
|
|
|
|
}
|
|
},
|
|
})
|
|
</script>
|
|
</html> |