HomeDocs
Skip to main content

navigation

Introduction

A customizable top navigation bar that supports configuring the home page and previous-page buttons.

Property Description

Property NameTypeDefault ValueRequiredDescription
typestringdefaultNoCustom navigation type. Currently only the default configuration is available.
backgroundColorstring#fffNoNavigation bar background color
frontColorstring#000NoForeground color (currently refers to font color)
opacitynumber1NoNavigation bar background transparency
navigationStyleobjectNoCustom style for the navigation container (added to inline style), using camel case for CSS property names
backIconbooleanfalseNoWhether to display the back icon
homeIconbooleanfalseNoWhether to display the home icon
backhdlEventHandleNoCallback event for clicking the back icon
homehdlEventHandleNoCallback event for clicking the home icon

Code Example

<dlt-navigation
bind:backhdl="backHandler"
bind:homehdl="homeHandler"
:navigationStyle="navigationStyle"
:opacity="opacity"
:backIcon="backIcon"
:homeIcon="homeIcon"
:backgroundColor="backgroundColor"
:frontColor="frontColor"
>
<text>Top Title</text>
</dlt-navigation>

<view class="page" :style="{'padding-top': navigationHeight + 'px'}">
<text>{{text}}</text>
</view>
.page {
background-color: #f4f5f9;
}
Page({
data: {
text: 'this is a blank page',
navigationStyle: {
fontSize: '18px',
},
frontColor: '#ff0',
opacity: 1,
backIcon: false,
homeIcon: false,
backgroundColor: 'white',
navigationHeight: 100,
type: 'default',
},
backHandler() {
console.log('navigate back');
},
homeHandler() {
console.log('navigate to home page');
},
onShow() {
const _this = this;
dlt.getSystemInfo({
success: function (res) {
const { capsuleTranslationY, capsuleHeight, pixelRatio } = res;
const navigationHeight =
(capsuleTranslationY +
capsuleHeight +
(capsuleTranslationY - capsuleHeight)) /
pixelRatio;
_this.setData({
navigationHeight,
});
},
});
},
});

Other Instructions

After using this component, it is recommended to leave the overall height of the navigation bar at the top of the page to avoid the page content being covered.

Calculation of the overall height of the top navigation bar:

Get device information using dlt.getSystemInfo, and calculate based on the returned content of the device information (in pixels):

const navigationHeight =
(capsuleTranslationY +
capsuleHeight +
(capsuleTranslationY - capsuleHeight)) /
pixelRatio;
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.