index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <uni-shadow-root class="weapp-lib-checkbox-group-index"><view :class="utils.bem('checkbox-group', [{ horizontal: direction === 'horizontal' }])">
  3. <slot></slot>
  4. </view></uni-shadow-root>
  5. </template>
  6. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  7. <script>
  8. global['__wxRoute'] = 'weapp/lib/checkbox-group/index'
  9. "use strict";
  10. Object.defineProperty(exports, "__esModule", { value: true });
  11. var relation_1 = require("../common/relation");
  12. var component_1 = require("../common/component");
  13. (0, component_1.VantComponent)({
  14. field: true,
  15. relation: (0, relation_1.useChildren)('checkbox', function (target) {
  16. this.updateChild(target);
  17. }),
  18. props: {
  19. max: Number,
  20. value: {
  21. type: Array,
  22. observer: 'updateChildren',
  23. },
  24. disabled: {
  25. type: Boolean,
  26. observer: 'updateChildren',
  27. },
  28. direction: {
  29. type: String,
  30. value: 'vertical',
  31. },
  32. },
  33. methods: {
  34. updateChildren: function () {
  35. var _this = this;
  36. this.children.forEach(function (child) { return _this.updateChild(child); });
  37. },
  38. updateChild: function (child) {
  39. var _a = this.data, value = _a.value, disabled = _a.disabled, direction = _a.direction;
  40. child.setData({
  41. value: value.indexOf(child.data.name) !== -1,
  42. parentDisabled: disabled,
  43. direction: direction,
  44. });
  45. },
  46. },
  47. });
  48. export default global['__wxComponents']['weapp/lib/checkbox-group/index']
  49. </script>
  50. <style platform="mp-weixin">
  51. @import '../common/index.css';.van-checkbox-group--horizontal{display:flex;flex-wrap:wrap}
  52. </style>