index.vue 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <uni-shadow-root class="vant-nav-bar-index"><view :class="(utils.bem('nav-bar', { fixed }))+' custom-class '+(border ? 'van-hairline--bottom' : '')" :style="'z-index: '+(zIndex)+'; padding-top: '+(safeAreaInsetTop ? statusBarHeight : 0)+'px;'">
  3. <view class="van-nav-bar__left" @click="onClickLeft">
  4. <block v-if="leftArrow || leftText">
  5. <van-icon v-if="leftArrow" size="16px" name="arrow-left" custom-class="van-nav-bar__arrow"></van-icon>
  6. <view v-if="leftText" class="van-nav-bar__text" hover-class="van-nav-bar__text--hover" hover-stay-time="70">{{ leftText }}</view>
  7. </block>
  8. <slot v-else name="left"></slot>
  9. </view>
  10. <view class="van-nav-bar__title title-class van-ellipsis">
  11. <block v-if="title">{{ title }}</block>
  12. <slot v-else name="title"></slot>
  13. </view>
  14. <view class="van-nav-bar__right" @click="onClickRight">
  15. <view v-if="rightText" class="van-nav-bar__text" hover-class="van-nav-bar__text--hover" hover-stay-time="70">{{ rightText }}</view>
  16. <slot v-else name="right"></slot>
  17. </view>
  18. </view></uni-shadow-root>
  19. </template>
  20. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  21. <script>
  22. import VanIcon from '../icon/index.vue'
  23. global['__wxVueOptions'] = {components:{'van-icon': VanIcon}}
  24. global['__wxRoute'] = 'vant/nav-bar/index'
  25. import { VantComponent } from '../common/component';
  26. VantComponent({
  27. classes: ['title-class'],
  28. props: {
  29. title: String,
  30. fixed: Boolean,
  31. leftText: String,
  32. rightText: String,
  33. leftArrow: Boolean,
  34. border: {
  35. type: Boolean,
  36. value: true
  37. },
  38. zIndex: {
  39. type: Number,
  40. value: 1
  41. },
  42. safeAreaInsetTop: {
  43. type: Boolean,
  44. value: true
  45. },
  46. },
  47. data: {
  48. statusBarHeight: 0
  49. },
  50. created() {
  51. const { statusBarHeight } = wx.getSystemInfoSync();
  52. this.setData({ statusBarHeight });
  53. },
  54. methods: {
  55. onClickLeft() {
  56. this.$emit('click-left');
  57. },
  58. onClickRight() {
  59. this.$emit('click-right');
  60. }
  61. }
  62. });
  63. export default global['__wxComponents']['vant/nav-bar/index']
  64. </script>
  65. <style platform="mp-weixin">
  66. @import '../common/index.css';.van-nav-bar{position:relative;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__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;bottom:0;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)}
  67. </style>