index.js 978 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var component_1 = require('../common/component');
  4. component_1.VantComponent({
  5. field: true,
  6. classes: ['node-class'],
  7. props: {
  8. checked: null,
  9. loading: Boolean,
  10. disabled: Boolean,
  11. activeColor: String,
  12. inactiveColor: String,
  13. size: {
  14. type: String,
  15. value: '30',
  16. },
  17. activeValue: {
  18. type: null,
  19. value: true,
  20. },
  21. inactiveValue: {
  22. type: null,
  23. value: false,
  24. },
  25. },
  26. methods: {
  27. onClick: function () {
  28. var _a = this.data,
  29. activeValue = _a.activeValue,
  30. inactiveValue = _a.inactiveValue,
  31. disabled = _a.disabled,
  32. loading = _a.loading;
  33. if (disabled || loading) {
  34. return;
  35. }
  36. var checked = this.data.checked === activeValue;
  37. var value = checked ? inactiveValue : activeValue;
  38. this.$emit('input', value);
  39. this.$emit('change', value);
  40. },
  41. },
  42. });