前端vue自定義導(dǎo)航欄組件高度及返回箭頭 自定義tabbar圖標(biāo)

前端vue自定義導(dǎo)航欄組件高度及返回箭頭 自定義tabbar圖標(biāo),?下載完整代碼請(qǐng)?jiān)L問uni-app插件市場(chǎng)地址:https://ext.dcloud.net.cn/plugin?id=12986

效果圖如下:


#

#### 使用方法

```使用方法

// page.json 采用矢量圖標(biāo)設(shè)置返回箭頭

? ? ,{

? ? ? ? ? ? "path" : "pages/Home/Home",

? ? ? ? ? ? "style" :? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? {

? ? ? ? ? ? ? ? "navigationBarTitleText": "首頁",

? ? ? ? ? ? ? ? "enablePullDownRefresh": false,

"app-plus": {

? ? ? ? ? ? ? ? ? ? "titleNView": {


? ? ? ? ? ? ? ? ? ? ? ? "buttons": [{


? ? ? ? ? ? ? ? ? ? ? ? ? ? "float": "left",

? ? ? ? ? ? ? ? ? ? ? ? ? ? "fontSize": "22px",

? ? ? ? ? ? ? ? ? ? ? ? ? ? "fontSrc": "/static/iconfont.ttf", // 字體文件

? ? ? ? ? ? ? ? ? ? ? ? ? ? "text": "" // 字體圖標(biāo)\u 開頭,加上字體圖標(biāo)unicode后面四位

? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? ? ? ]

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? }


}

? ? ? ? ? }




// 自定義導(dǎo)航欄高度

agentUserAgent() {

var agent = navigator.userAgent;

if (/iphone|ipad|ipod/i.test(agent)) {

if (document.querySelector('.titleIos'))

document.querySelector('.titleIos').style.display = 'block';

document.querySelector('.uni-page-head').style.paddingTop = '44px';

document.querySelector('.uni-page-head').style.height = '88px';

}

},

```

#### HTML代碼部分

```html

<template>

<view>

<view class="content">

<!-- 適配iOS導(dǎo)航欄高度 -->

<view class="titleIos"></view>

首頁

<button style="margin-top: 20px;" @click="goBackIndex">返回index頁面</button>

</view>

</view>

</template>

```

#### JS代碼 (引入組件 填充數(shù)據(jù))

```javascript

<script>

export default {

data() {

return {

}

},

onReady() {

// 自定義導(dǎo)航欄高度

this.agentUserAgent();

},

methods: {

// 自定義導(dǎo)航欄高度

agentUserAgent() {

var agent = navigator.userAgent;

if (/iphone|ipad|ipod/i.test(agent)) {

if (document.querySelector('.titleIos'))

document.querySelector('.titleIos').style.display = 'block';

document.querySelector('.uni-page-head').style.paddingTop = '44px';

document.querySelector('.uni-page-head').style.height = '88px';

}

},

// 返回菜單點(diǎn)擊

onNavigationBarButtonTap(e) {

if (e.index == 0) {

uni.redirectTo({

url: '/pages/index/index'

})

}

},

goBackIndex() {

uni.redirectTo({

url: '/pages/index/index'

})

}

}

}

</script>

```

#### CSS

```CSS

<style>

.content {

display: flex;

flex-direction: column;

align-items: center;

justify-content: center;

height: 100vh;

background: yellowgreen;

font-size: 26px;

}

</style>

```

?著作權(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)容

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