ColorUI provides a way to implement custom navigation bars by disabling the system default and using the cu-custom component.
1. Disable System Navigation
In your pages.json, set navigationStyle to custom within globalStyle.
2. Initialize System Information
You must capture system information (like status bar height) in App.vue and attach it to the Vue prototype so the custom component can calculate correct offsets for different platforms (WeChat, Alipay, etc.).
3. Register the Component
In main.js, import and register the cu-custom component globally.
4. Use the Component
Use the <cu-custom> component in your page files. You can customize the background, back button behavior, and content via props and slots.
// pages.json
"globalStyle": {
"navigationStyle": "custom"
}
// main.js
import cuCustom from './colorui/components/cu-custom.vue'
Vue.component('cu-custom', cuCustom)
<!-- page.vue -->
<cu-custom bgColor="bg-gradual-blue" :isBack="true">
<block slot="backText">返回</block>
<block slot="content">导航栏</block>
</cu-custom>