index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <view>
  3. <slot />
  4. </view>
  5. </template>
  6. <script>
  7. 'use strict';
  8. Object.defineProperty(exports, '__esModule', {
  9. value: true
  10. });
  11. var component_1 = require('../common/component');
  12. component_1.VantComponent({
  13. field: true,
  14. relation: {
  15. name: 'checkbox',
  16. type: 'descendant',
  17. current: 'checkbox-group',
  18. linked: function (target) {
  19. this.updateChild(target);
  20. }
  21. },
  22. props: {
  23. max: Number,
  24. value: {
  25. type: Array,
  26. observer: 'updateChildren'
  27. },
  28. disabled: {
  29. type: Boolean,
  30. observer: 'updateChildren'
  31. }
  32. },
  33. methods: {
  34. updateChildren: function () {
  35. var that = this;
  36. (this.children || []).forEach(function (child) {
  37. return that.updateChild(child);
  38. });
  39. },
  40. updateChild: function (child) {
  41. var _a = this;
  42. var value = _a.value;
  43. var disabled = _a.disabled;
  44. child.setData({
  45. value: value.indexOf(child.data.name) !== -1,
  46. parentDisabled: disabled
  47. });
  48. }
  49. }
  50. });
  51. </script>
  52. <style>
  53. @import './index.css';
  54. </style>