index.vue 1.3 KB

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