index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. (0, 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, activeValue = _a.activeValue, inactiveValue = _a.inactiveValue, disabled = _a.disabled, loading = _a.loading;
  29. if (disabled || loading) {
  30. return;
  31. }
  32. var checked = this.data.checked === activeValue;
  33. var value = checked ? inactiveValue : activeValue;
  34. this.$emit('input', value);
  35. this.$emit('change', value);
  36. },
  37. },
  38. });