用vue写一个淘宝导航菜单
时间: 2023-06-27 18:04:01 浏览: 39
好的,以下是一个简单的淘宝导航菜单的 Vue 组件:
```
<template>
<div class="tb-nav">
<ul>
<li v-for="(item, index) in navList" :key="index">
<a :href="item.link">{{ item.name }}</a>
</li>
</ul>
</div>
</template>
<script>
export default {
data() {
return {
navList: [
{
name: '女装',
link: 'https://nvz.taobao.com/'
},
{
name: '男装',
link: 'https://nanz.taobao.com/'
},
{
name: '鞋靴',
link: 'https://xie.taobao.com/'
},
{
name: '数码',
link: 'https://3c.taobao.com/'
},
{
name: '美妆',
link: 'https://mei.taobao.com/'
}
]
}
}
}
</script>
<style scoped>
.tb-nav ul {
display: flex;
}
.tb-nav li {
margin-right: 20px;
}
.tb-nav a {
color: #333;
text-decoration: none;
}
</style>
```
这个组件使用了 `v-for` 来循环遍历 `navList` 数组,生成导航菜单项。同时,使用了 CSS Flex 布局来水平排列菜单项,样式可以根据需要自行调整。