vue实现首页导航面板组件

效果图

 

 

src/pages/home/nav.vue

<template>
    <div class="nav">
        <ul class="nav-list">
            <li class="nav-item" v-for="(nav,index) in navItems" :key="index">
                <a :href="nav.linkUrl" class="nav-link">
                    <img :src="nav.picUrl" alt="" class="nav-pic">
                    <p class="nav-title">{{nav.text}}</p>
                </a>
            </li>
        </ul>
    </div>
</template>

<script>
export default {
    name:'HomeNav',data(){
        return{
            navItems:[
                {
                    linkUrl:'www.baidu.com'),text:'团购'
                },{
                    linkUrl:'www.baidu.com''assets/img/nav/nav-item-3.png''assets/img/nav/nav-item-5.png''assets/img/nav/nav-item-7.png''assets/img/nav/nav-item-9.png'
                }
            ],}
    }
}
</script>

<style scoped>
    .nav{
        width:100%;
        padding-top:15px;
        background:#fff;
    }
    .nav-list{
        display:flex;
        flex-wrap:wrap;
    }
    .nav-item{
        width:20%;
    }
    .nav-link{
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        margin-bottom:15px;
    }
    .nav-pic{
        width:60%;
        margin-bottom:7px;
    }
</style>

 

src/pages/home/index.vue

<template>
    <div class="home">
        <scrollbar>
            <slider />
            <home-nav />
        </scrollbar>
        <!-- 该页面自己的子路由 -->
        <router-view></router-view>
    </div>

</template>

<script>
import Slider from 'components/slider';
import Scrollbar from 'components/scroll';
import HomeNav from './nav';

export  {
    name:"Home"
    .home{
        width:100%;
        height:100%;
    }
</style>

 

src/assets/scss/index.scss

@import 'icons';

*{
    margin:0;
    padding:0;
}
html,body{
    // 必须设置,否则内容滚动效果无法实现
    width:100%;
    height:100%;
}
ul,li{
    list-style:none;
}
a{
    text-decoration: none;
    color:#333;
}

 

相关文章

https://segmentfault.com/a/1190000022018995 https://www....
ES6 (ECMAScript 6)中的模块是一个包含 JavaScript 代码的...
from https://mp.weixin.qq.com/s/-rc1lYYlsfx-wR4mQmIIQQ V...
D:\Temp&gt;npm init vite@latest vue3study --temp...
文章浏览阅读1.2k次。最近自己从零撸起的甘特图组件需要子组...
文章浏览阅读3.3k次,点赞3次,收藏16次。静默打印是什么?简...