index.vue 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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)+'; '+(safeAreaInsetTop ? 'padding-top: ' + statusBarHeight + '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. import { safeArea } from '../mixins/safe-area';
  27. VantComponent({
  28. mixins: [safeArea({ safeAreaInsetTop: true })],
  29. classes: ['title-class'],
  30. props: {
  31. title: String,
  32. fixed: Boolean,
  33. leftText: String,
  34. rightText: String,
  35. leftArrow: Boolean,
  36. border: {
  37. type: Boolean,
  38. value: true
  39. },
  40. zIndex: {
  41. type: Number,
  42. value: 120
  43. }
  44. },
  45. methods: {
  46. onClickLeft() {
  47. this.$emit('click-left');
  48. },
  49. onClickRight() {
  50. this.$emit('click-right');
  51. }
  52. }
  53. });
  54. export default global['__wxComponents']['vant/nav-bar/index']
  55. </script>
  56. <style platform="mp-weixin">
  57. @import '../common/index.css';.van-nav-bar{position:relative;height:44px;line-height:44px;text-align:center;background-color:#fff;-webkit-user-select:none;user-select:none}.van-nav-bar__text{display:inline-block;padding:0 15px;margin:0 -15px;color:#1989fa;vertical-align:middle}.van-nav-bar__text--hover{background-color:#f2f3f5}.van-nav-bar__arrow{color:#1989fa;vertical-align:middle}.van-nav-bar__arrow+.van-nav-bar__text{padding-left:25px;margin-left:-20px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;font-size:16px;font-weight:500}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px}.van-nav-bar__left{left:15px}.van-nav-bar__right{right:15px}
  58. </style>