index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. exports.__esModule = true;
  3. exports["default"] = void 0;
  4. var _utils = require("../utils");
  5. var _use = (0, _utils.use)('tabbar'),
  6. sfc = _use[0],
  7. bem = _use[1];
  8. var _default = sfc({
  9. data: function data() {
  10. return {
  11. items: []
  12. };
  13. },
  14. props: {
  15. value: Number,
  16. activeColor: String,
  17. safeAreaInsetBottom: Boolean,
  18. fixed: {
  19. type: Boolean,
  20. "default": true
  21. },
  22. zIndex: {
  23. type: Number,
  24. "default": 1
  25. }
  26. },
  27. watch: {
  28. items: function items() {
  29. this.setActiveItem();
  30. },
  31. value: function value() {
  32. this.setActiveItem();
  33. }
  34. },
  35. methods: {
  36. setActiveItem: function setActiveItem() {
  37. var _this = this;
  38. this.items.forEach(function (item, index) {
  39. item.active = index === _this.value;
  40. });
  41. },
  42. onChange: function onChange(active) {
  43. if (active !== this.value) {
  44. this.$emit('input', active);
  45. this.$emit('change', active);
  46. }
  47. }
  48. },
  49. render: function render(h) {
  50. return h("div", {
  51. "style": {
  52. zIndex: this.zIndex
  53. },
  54. "class": ['van-hairline--top-bottom', bem({
  55. fixed: this.fixed,
  56. 'safe-area-inset-bottom': this.safeAreaInsetBottom
  57. })]
  58. }, [this.slots()]);
  59. }
  60. });
  61. exports["default"] = _default;