index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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: '30px'
  16. },
  17. activeValue: {
  18. type: null,
  19. value: true
  20. },
  21. inactiveValue: {
  22. type: null,
  23. value: false
  24. }
  25. },
  26. watch: {
  27. checked: function (value) {
  28. this.set({ value: value });
  29. }
  30. },
  31. created: function () {
  32. this.set({ value: this.data.checked });
  33. },
  34. methods: {
  35. onClick: function () {
  36. var _a = this.data, activeValue = _a.activeValue, inactiveValue = _a.inactiveValue;
  37. if (!this.data.disabled && !this.data.loading) {
  38. var checked = this.data.checked === activeValue;
  39. var value = checked ? inactiveValue : activeValue;
  40. this.$emit('input', value);
  41. this.$emit('change', value);
  42. }
  43. }
  44. }
  45. });