使用ul标签制作简单的菜单(vue模板)
先看一下效果图:

简单粗暴,上代码:
<template>
<div class="listMenu-wrap">
<ul class="list-ul" v-for="(item, index) in data" :key="index">
<li :class="[currentIndex === index ? 'active' : '']" @click="handleClick(index, item)">{{item}}</li>
</ul>
</div>
</template>
<script>
export default {
name: "ListMenu",
data() {
return {
currentIndex: 0,
data:[
"项目列表1",
"项目列表2",
"项目列表3",
"项目列表4"
]
}
},
methods: {
handleClick(index, item) {
this.currentIndex = index
}
}
}
</script>
<style scoped lang="scss">
.listMenu-wrap{
.list-ul {
list-style: none;
margin: 0;
padding: 0;
li{
line-height: 30px;
font-size: 16px;
padding: 3px 15px;
&:hover{
cursor: pointer;
background-color: rgba(69, 86, 118, 0.44);
color: #ffffff;
}
}
}
.active{
color: #409EFF;
}
}
</style>

浙公网安备 33010602011771号