34 lines
937 B
JavaScript
34 lines
937 B
JavaScript
/**
|
|
* NavBar 自定义导航栏(规范 §17)
|
|
*
|
|
* 用于非 tabBar 页面:返回按钮 + 标题 + 右侧操作 slot。
|
|
* statusBarHeight / navBarHeight 由调用方 app.js 通过 wx.getSystemInfoSync 注入。
|
|
* 用法:
|
|
* <ui-nav-bar title="编辑资料" show-back bind:back="onBack" />
|
|
*/
|
|
Component({
|
|
options: { addGlobalClass: true, multipleSlots: true },
|
|
properties: {
|
|
title: { type: String, value: '' },
|
|
showBack: { type: Boolean, value: true },
|
|
statusBarHeight: { type: Number, value: 20 },
|
|
navBarHeight: { type: Number, value: 44 },
|
|
bg: { type: String, value: 'card' }, // card | transparent
|
|
},
|
|
data: {
|
|
containerStyle: '',
|
|
},
|
|
observers: {
|
|
'statusBarHeight, navBarHeight'(s, n) {
|
|
this.setData({
|
|
containerStyle: `padding-top: ${s}px; height: ${s + n}px;`,
|
|
});
|
|
},
|
|
},
|
|
methods: {
|
|
onBack() {
|
|
this.triggerEvent('back', {});
|
|
},
|
|
},
|
|
});
|