0
点赞
收藏
分享

微信扫一扫

vue单页面实现tabBar

千妈小语 2022-02-17 阅读 45
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <title>底部导航</title>
    <meta name="keywords" content="关键字" />
    <meta name="description" content="本页描述或关键字描述" />
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no">
    <style>
        .footer-wrap{
            position: fixed;
            width: 100%;
            bottom: 0px;
            left: 0px;
            right: 0px;
            background: #ffffff;
            z-index: 999;
            height: 68px;
            display: flex;
            justify-content: space-around;
        }
        .tab-item{
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            /* border: 1px solid red; */
            width: 33%;
        }
        .tab-img{
            width: 26px;
            margin-bottom: 3px;
        }
        .tab-title{
            font-size: 12px;
            color: #6F6F6F;
        }
        .tab-title-active{
            color: #26B0FF;
        }
    </style>
</head>
<body style="margin: 0px;padding: 0px;background: #EDEDED;">
    <div class="footer-wrap" id="tapBar">
        <div class="tab-item" v-for="item in tabBarList" @click="jumpUrl(item)">
            <img class="tab-img" :src=" item.page == index ? item.rightImg : item.huiImg">
            <span class="tab-title" :class="item.page == index ? 'tab-title-active' : ''">{{item.title}}</span>
        </div>
    </div>
</body>
<script src="../js/jquery-1.11.1.min.js"></script>
<script src="../js/vue@2.js"></script>
<script>
    var app = new Vue({
        el: '#tapBar',
        data: {
            name: 'aaa',
            index: 1,
            tabBarList: [
                {
                    page: 1,
                    rightImg: '../img/now-zd.png',
                    huiImg: '../img/now-zd-hui.png',
                    title: '当期账单',
                    url: '/accountStatement.html'
                },
                {
                    page: 2,
                    rightImg: '../img/old-zd.png',
                    huiImg: '../img/old-zd-hui.png',
                    title: '历史账单',
                    url: '/historicalBill.html'
                },
                {
                    page: 3,
                    rightImg: '../img/merchant-right.png',
                    huiImg: '../img/merchant-right-hui.png',
                    title: '商户信息',
                    url: '/merchantInfo.html'
                }
            ]
        },
        creater() {},
        methods: {
            jumpUrl(data) {
                console.log(data)
                this.index = data.page
                window.location.href = data.url
            }
        }
    })
</script>
举报

相关推荐

0 条评论