Home > Web Front-end > uni-app > body text

How to implement custom navigation bar in uniapp

coldplay.xixi
Release: 2020-12-17 10:22:33
Original
9423 people have browsed it

Uniapp implements the method of customizing the navigation bar: using a view, the code is [, ].

How to implement custom navigation bar in uniapp

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, this method is suitable for all brands of computers.

Recommended (free): uni-app development tutorial

uniapp implements custom navigation bar Method:

Close the default navigation bar on a single page

"navigationStyle": "custom"
Copy after login

The officially obtained parameters are

How to implement custom navigation bar in uniapp

Parameter details

How to implement custom navigation bar in uniapp

Implementation principle

Use a view, padding-top=top;height=height;padding-bottom=give it to the one you like The value of rpx

The code implemented

<template>
    <view>
        <view :style="&#39;height:&#39; +  demo.height + &#39;px;&#39; + &#39;padding-top:&#39; + demo.top + &#39;px;padding-bottom:10rpx&#39;">
            <view :style="&#39;top:&#39; + demo.top + &#39;px&#39;">
                <view class="iconfont icon-xiaoxi"></view>
            </view>
            测试辣
        </view>
    </view>
</template>
<script>
    export default {
        data () {
            return {
                demo: {
                    top: 0,
                    height: 0
                }
            }
        },
        created () {
            const demo = uni.getMenuButtonBoundingClientRect()
            this.demo.top = demo.top
            this.demo.height = demo.height
        }
    }
</script>
<style>
    .demo{
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;
        font-size: 26rpx;
        .left{
            float: left;
            position: absolute;
            width: max-content;
            height: max-content;
            top: 0;
            bottom: 0;
            left: 20rpx;
            margin: auto;
            .iconfont{
                color: #3C3C3C;
            }
        }
    }
</style>
Copy after login

Effect

How to implement custom navigation bar in uniapp

##Related free learning recommendations:

php programming(video)

The above is the detailed content of How to implement custom navigation bar in uniapp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template