Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program API set the navigation bar


May 19, 2021 WeChat Mini Program Development Document


Table of contents


wx.setNavigationBarTitle(OBJECT)


Dynamically set the title of the current page.

OBJECT parameter description:

Parameters Type Required Description
title String Is The title of the page
success Function Whether The interface calls a successful callback function
fail Function Whether The interface calls the failed callback function
complete Function Whether Callback function at end of interface call (call succeeds, fails are executed)

Example code:

wx.setNavigationBarTitle({
  title: '当前页面'
})

wx.showNavigationBarLoading()

The navigation bar load animation is displayed on the current page.

wx.hideNavigationBarLoading()

Hide the navigation bar loading animation.

wx.setNavigationBarColor(OBJECT)

Base library 1.4.0 starts to support, and low versions need to be compatible

OBJECT parameter description:

The name of the argument Type Required Description
frontColor String Is Foreground color values, including buttons, titles, and status bar colors, support only #ffffff and #000000
backgroundColor String Is Background color value, the effective value is hete sixteen-color
animation Object Whether Animated effects
animation.duration Number Whether Animation change time, default 0, in milliseconds
animation.timingFunc String Whether How the animation changes, the default linear
success Function Whether The interface calls a successful callback function
fail Function Whether The interface calls the failed callback function
complete Function Whether Callback function at end of interface call (call succeeds, fails are executed)

Animation.timingFunc valid value:

Value Description
linear The speed of the animation is the same from start to finish.
easeIn The animation starts at a low speed
easeOut The animation ends at a low speed.
easeInOut The animation starts and ends at a low speed.

Success returns a description of the parameters:

The name of the argument Type Description
errMsg String The result of the call

Example code:

wx.setNavigationBarColor({
    frontColor: '#ffffff',
    backgroundColor: '#ff0000',
    animation: {
        duration: 400,
        timingFunc: 'easeIn'
    }
})