index.js 746 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { VantComponent } from '../common/component';
  2. VantComponent({
  3. field: true,
  4. classes: ['node-class'],
  5. props: {
  6. checked: Boolean,
  7. loading: Boolean,
  8. disabled: Boolean,
  9. activeColor: String,
  10. inactiveColor: String,
  11. size: {
  12. type: String,
  13. value: '30px'
  14. }
  15. },
  16. watch: {
  17. checked: function checked(value) {
  18. this.set({
  19. value: value
  20. });
  21. }
  22. },
  23. created: function created() {
  24. this.set({
  25. value: this.data.checked
  26. });
  27. },
  28. methods: {
  29. onClick: function onClick() {
  30. if (!this.data.disabled && !this.data.loading) {
  31. var checked = !this.data.checked;
  32. this.$emit('input', checked);
  33. this.$emit('change', checked);
  34. }
  35. }
  36. }
  37. });