uni-app使用ColorUi自定義頂部標(biāo)題

App.vue 引入關(guān)鍵Css main.css icon.css

<style>
    @import "colorui/main.css";
    @import "colorui/icon.css";
    @import "app.css"; /* 你的項(xiàng)目css */
    ....
</style>

App.vue 獲得系統(tǒng)信息,必須要引入 import Vue from 'vue',忘記的話高度不能獲取設(shè)置

import Vue from 'vue'
export default {
      onLaunch: function() {
            uni.getSystemInfo({
                success: function(e) {
                    // #ifndef MP
                    Vue.prototype.StatusBar = e.statusBarHeight;
                    if (e.platform == 'android') {
                        Vue.prototype.CustomBar = e.statusBarHeight + 50;
                    } else {
                        Vue.prototype.CustomBar = e.statusBarHeight + 45;
                    };
                    // #endif

                    // #ifdef MP-WEIXIN
                    Vue.prototype.StatusBar = e.statusBarHeight;
                    let custom = wx.getMenuButtonBoundingClientRect();
                    Vue.prototype.Custom = custom;
                    Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
                    // #endif       

                    // #ifdef MP-ALIPAY
                    Vue.prototype.StatusBar = e.statusBarHeight;
                    Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
                    // #endif
                }
            })

            Vue.prototype.ColorList = [{
                    title: '嫣紅',
                    name: 'red',
                    color: '#e54d42'
                },
                {
                    title: '桔橙',
                    name: 'orange',
                    color: '#f37b1d'
                },
                {
                    title: '明黃',
                    name: 'yellow',
                    color: '#fbbd08'
                },
                {
                    title: '橄欖',
                    name: 'olive',
                    color: '#8dc63f'
                },
                {
                    title: '森綠',
                    name: 'green',
                    color: '#39b54a'
                },
                {
                    title: '天青',
                    name: 'cyan',
                    color: '#1cbbb4'
                },
                {
                    title: '海藍(lán)',
                    name: 'blue',
                    color: '#0081ff'
                },
                {
                    title: '姹紫',
                    name: 'purple',
                    color: '#6739b6'
                },
                {
                    title: '木槿',
                    name: 'mauve',
                    color: '#9c26b0'
                },
                {
                    title: '桃粉',
                    name: 'pink',
                    color: '#e03997'
                },
                {
                    title: '棕褐',
                    name: 'brown',
                    color: '#a5673f'
                },
                {
                    title: '玄灰',
                    name: 'grey',
                    color: '#8799a3'
                },
                {
                    title: '草灰',
                    name: 'gray',
                    color: '#aaaaaa'
                },
                {
                    title: '墨黑',
                    name: 'black',
                    color: '#333333'
                },
                {
                    title: '雅白',
                    name: 'white',
                    color: '#ffffff'
                },
            ]

        },

pages.json 配置取消系統(tǒng)導(dǎo)航欄

"pages": [ //pages數(shù)組中第一項(xiàng)表示應(yīng)用啟動(dòng)頁,參考:https://uniapp.dcloud.io/collocation/pages
        {
            "path": "pages/index/index",
            "style": {
                "navigationStyle": "custom"
            }
        }

使用封裝,在main.js 引入 cu-custom 組件。

import cuCustom from './colorui/components/cu-custom.vue'
Vue.component('cu-custom',cuCustom)

index.vue 頁面可以直接調(diào)用了

<cu-custom bgColor="bg-gradual-blue" :isBack="true">
    <block slot="backText">返回</block>
    <block slot="content">導(dǎo)航欄</block>
</cu-custom>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、項(xiàng)目結(jié)構(gòu)介紹 pages.json:配置頁面路由、導(dǎo)航條、選項(xiàng)卡等頁面類信息,詳見。manifest.json...
    移動(dòng)端_小剛哥閱讀 3,245評(píng)論 0 4
  • 33、JS中的本地存儲(chǔ) 把一些信息存儲(chǔ)在當(dāng)前瀏覽器指定域下的某一個(gè)地方(存儲(chǔ)到物理硬盤中)1、不能跨瀏覽器傳輸:在...
    萌妹撒閱讀 2,258評(píng)論 0 2
  • 基于Vue的一些資料 內(nèi)容 UI組件 開發(fā)框架 實(shí)用庫 服務(wù)端 輔助工具 應(yīng)用實(shí)例 Demo示例 element★...
    嘗了又嘗閱讀 1,297評(píng)論 0 1
  • 如圖,通過maven project創(chuàng)建了個(gè)web app項(xiàng)目: 配置個(gè)tomcat : 運(yùn)行調(diào)試,發(fā)現(xiàn)生成的ta...
    小狼在IT閱讀 4,068評(píng)論 0 3
  • [玫瑰]如果你是一名基金經(jīng)理,準(zhǔn)備管理一支貨幣基金。你覺得你管理的這個(gè)基金,可以給它的投資者們帶來哪些便利或好處?
    洛克君君_58ec閱讀 91評(píng)論 0 0

友情鏈接更多精彩內(nèi)容