index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
  2. import { use, noop } from '../utils';
  3. import { inherit } from '../utils/functional';
  4. import Icon from '../icon'; // Types
  5. var _use = use('nav-bar'),
  6. sfc = _use[0],
  7. bem = _use[1];
  8. function NavBar(h, props, slots, ctx) {
  9. return h("div", _mergeJSXProps([{
  10. "class": [bem({
  11. fixed: props.fixed
  12. }), {
  13. 'van-hairline--bottom': props.border
  14. }],
  15. "style": {
  16. zIndex: props.zIndex
  17. }
  18. }, inherit(ctx)]), [h("div", {
  19. "class": bem('left'),
  20. "on": {
  21. "click": ctx.listeners['click-left'] || noop
  22. }
  23. }, [slots.left ? slots.left() : [props.leftArrow && h(Icon, {
  24. "class": bem('arrow'),
  25. "attrs": {
  26. "name": "arrow-left"
  27. }
  28. }), props.leftText && h("span", {
  29. "class": bem('text')
  30. }, [props.leftText])]]), h("div", {
  31. "class": [bem('title'), 'van-ellipsis']
  32. }, [slots.title ? slots.title() : props.title]), h("div", {
  33. "class": bem('right'),
  34. "on": {
  35. "click": ctx.listeners['click-right'] || noop
  36. }
  37. }, [slots.right ? slots.right() : props.rightText && h("span", {
  38. "class": bem('text')
  39. }, [props.rightText])])]);
  40. }
  41. NavBar.props = {
  42. title: String,
  43. fixed: Boolean,
  44. leftText: String,
  45. rightText: String,
  46. leftArrow: Boolean,
  47. border: {
  48. type: Boolean,
  49. "default": true
  50. },
  51. zIndex: {
  52. type: Number,
  53. "default": 1
  54. }
  55. };
  56. export default sfc(NavBar);