1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
| <template>
| <uni-shadow-root class="vant-nav-bar-index"><view v-if="fixed && placeholder" :style="'height: '+(height)+'px;'"></view>
|
| <view :class="(utils.bem('nav-bar', { fixed }))+' custom-class '+(border ? 'van-hairline--bottom' : '')" :style="(baseStyle)+'; '+(customStyle)">
| <view class="van-nav-bar__content">
| <view class="van-nav-bar__left" @click="onClickLeft">
| <block v-if="leftArrow || leftText">
| <van-icon v-if="leftArrow" size="16px" name="arrow-left" custom-class="van-nav-bar__arrow"></van-icon>
| <view v-if="leftText" class="van-nav-bar__text" hover-class="van-nav-bar__text--hover" hover-stay-time="70">{{ leftText }}</view>
| </block>
| <slot v-else name="left"></slot>
| </view>
| <view class="van-nav-bar__title title-class van-ellipsis">
| <block v-if="title">{{ title }}</block>
| <slot v-else name="title"></slot>
| </view>
| <view class="van-nav-bar__right" @click="onClickRight">
| <view v-if="rightText" class="van-nav-bar__text" hover-class="van-nav-bar__text--hover" hover-stay-time="70">{{ rightText }}</view>
| <slot v-else name="right"></slot>
| </view>
| </view>
| </view></uni-shadow-root>
| </template>
| <wxs src="../wxs/utils.wxs" module="utils"></wxs>
| <script>
| import VanIcon from '../icon/index.vue'
| global['__wxVueOptions'] = {components:{'van-icon': VanIcon}}
|
| global['__wxRoute'] = 'vant/nav-bar/index'
| import { VantComponent } from '../common/component';
| import { getSystemInfoSync } from '../common/utils';
| VantComponent({
| classes: ['title-class'],
| props: {
| title: String,
| fixed: {
| type: Boolean,
| observer: 'setHeight',
| },
| placeholder: {
| type: Boolean,
| observer: 'setHeight',
| },
| leftText: String,
| rightText: String,
| customStyle: String,
| leftArrow: Boolean,
| border: {
| type: Boolean,
| value: true,
| },
| zIndex: {
| type: Number,
| value: 1,
| },
| safeAreaInsetTop: {
| type: Boolean,
| value: true,
| },
| },
| data: {
| statusBarHeight: 0,
| height: 44,
| baseStyle: '',
| },
| created() {
| const { statusBarHeight } = getSystemInfoSync();
| const { safeAreaInsetTop, zIndex } = this.data;
| const paddingTop = safeAreaInsetTop ? statusBarHeight : 0;
| const baseStyle = `z-index: ${zIndex};padding-top: ${paddingTop}px;`;
| this.setData({
| statusBarHeight,
| height: 44 + statusBarHeight,
| baseStyle,
| });
| },
| mounted() {
| this.setHeight();
| },
| methods: {
| onClickLeft() {
| this.$emit('click-left');
| },
| onClickRight() {
| this.$emit('click-right');
| },
| setHeight() {
| if (!this.data.fixed || !this.data.placeholder) {
| return;
| }
| wx.nextTick(() => {
| this.getRect('.van-nav-bar').then((res) => {
| this.setData({ height: res.height });
| });
| });
| },
| },
| });
| export default global['__wxComponents']['vant/nav-bar/index']
| </script>
| <style platform="mp-weixin">
| @import '../common/index.css';.van-nav-bar{text-align:center;-webkit-user-select:none;user-select:none;height:44px;height:var(--nav-bar-height,44px);line-height:44px;line-height:var(--nav-bar-height,44px);background-color:#fff;background-color:var(--nav-bar-background-color,#fff)}.van-nav-bar,.van-nav-bar__content{position:relative}.van-nav-bar__text{display:inline-block;vertical-align:middle;margin:0 -16px;margin:0 -var(--padding-md,16px);padding:0 16px;padding:0 var(--padding-md,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__text--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-nav-bar__arrow{vertical-align:middle;font-size:16px;font-size:var(--nav-bar-arrow-size,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;color:#323233;color:var(--nav-bar-title-text-color,#323233);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--nav-bar-title-font-size,16px)}.van-nav-bar__left,.van-nav-bar__right{position:absolute;top:0;bottom:0;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;font-size:14px;font-size:var(--font-size-md,14px)}.van-nav-bar__left{left:16px;left:var(--padding-md,16px)}.van-nav-bar__right{right:16px;right:var(--padding-md,16px)}
| </style>
|
|