index.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <uni-shadow-root class="vant-checkbox-group-index"><slot></slot></uni-shadow-root>
  3. </template>
  4. <script>
  5. global['__wxRoute'] = 'vant/checkbox-group/index'
  6. import { VantComponent } from '../common/component';
  7. VantComponent({
  8. field: true,
  9. relation: {
  10. name: 'checkbox',
  11. type: 'descendant',
  12. current: 'checkbox-group',
  13. linked(target) {
  14. this.updateChild(target);
  15. },
  16. },
  17. props: {
  18. max: Number,
  19. value: {
  20. type: Array,
  21. observer: 'updateChildren',
  22. },
  23. disabled: {
  24. type: Boolean,
  25. observer: 'updateChildren',
  26. },
  27. },
  28. methods: {
  29. updateChildren() {
  30. (this.children || []).forEach((child) => this.updateChild(child));
  31. },
  32. updateChild(child) {
  33. const { value, disabled } = this.data;
  34. child.setData({
  35. value: value.indexOf(child.data.name) !== -1,
  36. parentDisabled: disabled,
  37. });
  38. },
  39. },
  40. });
  41. export default global['__wxComponents']['vant/checkbox-group/index']
  42. </script>
  43. <style platform="mp-weixin">
  44. @import '../common/index.css';
  45. </style>