123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <template>
- <view
- class="u-radio-group"
- :class="bemClass"
- :style="radioGroupStyle"
- >
- <slot></slot>
- </view>
- </template>
- <script>
- import { props } from './props';
- import { mpMixin } from '../../libs/mixin/mpMixin';
- import { mixin } from '../../libs/mixin/mixin';
- import { addUnit, addStyle, deepMerge } from '../../libs/function/index';
-
- export default {
- name: 'u-radio-group',
- mixins: [mpMixin, mixin, props],
- computed: {
-
-
-
- parentData() {
-
- return [this.modelValue, this.disabled, this.inactiveColor, this.activeColor, this.size, this.labelDisabled, this.shape,
- this.iconSize, this.borderBottom, this.placement
- ]
-
-
- return [this.value, this.disabled, this.inactiveColor, this.activeColor, this.size, this.labelDisabled, this.shape,
- this.iconSize, this.borderBottom, this.placement
- ]
-
-
- },
- bemClass() {
-
- return this.bem('radio-group', ['placement'])
- },
- radioGroupStyle() {
- const style = {
- gap: addUnit(this.gap)
- };
- return deepMerge(style, addStyle(this.customStyle));
- }
- },
- watch: {
-
- parentData() {
- if (this.children.length) {
- this.children.map(child => {
-
- typeof(child.init) === 'function' && child.init()
- })
- }
- },
- },
- data() {
- return {
- }
- },
- created() {
- this.children = []
- },
-
- emits: ['update:modelValue', 'change'],
-
- methods: {
-
- unCheckedOther(childInstance) {
- this.children.map(child => {
-
- if (childInstance !== child) {
- child.checked = false
- }
- })
- const {
- name
- } = childInstance
-
-
- this.$emit("update:modelValue", name);
-
-
- this.$emit("input", name);
-
-
- this.$emit('change', name)
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- @import "../../libs/css/components.scss";
- .u-radio-group {
- flex: 1;
- &--row {
-
- display: flex;
-
- flex-flow: row wrap;
- }
- &--column {
- @include flex(column);
- }
- }
- </style>
|