vue框架:vue官方文檔html
mpvue框架:mpvue官方文檔vue
"navigationStyle": "custom"複製代碼
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black",
"navigationStyle": "custom" // 這個配置
}複製代碼
├── src 源碼目錄
│ ├── main.js 入口js文件
│ ├── app.json 全局配置
│ ├── components 組件目錄
│ │ └── common 公共組件
└── topBar.vue 頂部自定義導航複製代碼
const that = this
let systemInfo = wx.getSystemInfoSync()
that.setBarHeight(systemInfo.statusBarHeight)複製代碼
<template>
<div class="top-bar">
<div class="bar" :style="'height:'+(systemInfo.barHeight+46)+'px;'">
<span class="title">{{title}}</span>
<button v-if="way && way==='/pages/mine/main'" open-type="getUserInfo" @getuserinfo="toMine">
<image class="icon" :src="icon" />
</button>
<image v-else-if="way && way!=='/pages/mine/main'" class="icon-back" :src="icon" @tap="toPage(way)" />
<span v-else></span>
</div>
<p class="place-holder" :style="'padding-top:'+(systemInfo.barHeight+6)+'px;'"></p>
</div>
</template>複製代碼
props: {
title: {
type: String,
required: true
},
icon: {
type: String,
default: require('@static/icon/icon_back.png')
},
way: {
type: String,
default: null
}
}複製代碼