index.js 897 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { createNamespace } from '../utils';
  2. import { ParentMixin } from '../mixins/relation';
  3. var _createNamespace = createNamespace('sidebar'),
  4. createComponent = _createNamespace[0],
  5. bem = _createNamespace[1];
  6. export default createComponent({
  7. mixins: [ParentMixin('vanSidebar')],
  8. model: {
  9. prop: 'activeKey'
  10. },
  11. props: {
  12. activeKey: {
  13. type: [Number, String],
  14. default: 0
  15. }
  16. },
  17. data: function data() {
  18. return {
  19. index: +this.activeKey
  20. };
  21. },
  22. watch: {
  23. activeKey: function activeKey() {
  24. this.setIndex(+this.activeKey);
  25. }
  26. },
  27. methods: {
  28. setIndex: function setIndex(index) {
  29. if (index !== this.index) {
  30. this.index = index;
  31. this.$emit('change', index);
  32. }
  33. }
  34. },
  35. render: function render() {
  36. var h = arguments[0];
  37. return h("div", {
  38. "class": bem()
  39. }, [this.slots()]);
  40. }
  41. });