首页 > 其他 > 详细

Vue底部菜单模块

时间:2020-11-27 13:59:15      阅读:38      评论:0      收藏:0      [点我收藏+]

写好的直接用,可指定模块,引入在主页面即可

index.vue

<template>
    <div>
        <Footer specify="如果需要指定页面填写路径即可"></Footer>
    </div>
</template>

<script>
    import Footer from ‘../components/footer.vue‘;
    export default {
        components: {
            Footer
        },
        data() {
            return {}
        },
        methods: {}
    }
</script>

<style>
</style>

 

footer.vue

<template>
    <div class="footer">
        <ul class="muen-list">
            <li v-for="(item,index) in muenList" @click="go(item.link)">
                <img v-if="path==item.link" :src="item.inc2">
                <img v-else :src="item.inc">
                {{item.text}}
            </li>
        </ul>
    </div>
</template>

<script>
    export default {
        props: {
            specify: {
                type: String,
                default: ‘‘
            }
        },
        data() {
            return {
                muenList: [{
                        inc: require("../src/assets/images/home1.png"),
                        inc2: require("../src/assets/images/home2.png"),
                        link: ‘/index‘,
                        text: ‘首页‘
                    },
                    {
                        inc: require("../src/assets/images/notice1.png"),
                        inc2: require("../src/assets/images/notice2.png"),
                        link: ‘/notice‘,
                        text: ‘公告‘
                    },
                    {
                        inc: require("../src/assets/images/group1.png"),
                        inc2: require("../src/assets/images/group2.png"),
                        link: ‘/group‘,
                        text: ‘分组‘
                    },
                    {
                        inc: require("../src/assets/images/user1.png"),
                        inc2: require("../src/assets/images/user2.png"),
                        link: ‘/user‘,
                        text: ‘我的‘
                    },
                ],
                path: ‘‘
            }
        },
        created() {
                this.specify ? this.path = this.specify : this.path = this.$route.path == ‘/‘ ? ‘/index‘ : this.$route.path;

        },
        methods: {
            go(link) {
                this.$router.push(link);
            }
        }
    }
</script>

<style>
    .footer {
        width: 100%;
        position: fixed;
        bottom: 0;
        z-index: 10;
    }

    .muen-list {
        display: flex;
        width: 100%;
        background-color: #fff;
    }

    .muen-list li {
        width: 25%;
        display: flex;
        justify-content: center;
        flex-direction: column;
        align-items: center;
        font-size: .5rem;
        padding: .3rem;
    }

    .muen-list img {
        width: 1.5rem;
    }
</style>

 

Vue底部菜单模块

原文:https://www.cnblogs.com/xuanjiange/p/14047067.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!