From da25434b85fc5b4321c429bf95e719d00ec395bb Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Thu, 11 Jan 2024 16:21:16 +0800 Subject: [PATCH] 定位优化 --- uni_modules/uview-ui/components/u-radio-group/u-radio-group.vue | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-) diff --git a/uni_modules/uview-ui/components/u-radio-group/u-radio-group.vue b/uni_modules/uview-ui/components/u-radio-group/u-radio-group.vue new file mode 100644 index 0000000..0d3c9b5 --- /dev/null +++ b/uni_modules/uview-ui/components/u-radio-group/u-radio-group.vue @@ -0,0 +1,108 @@ +<template> + <view + class="u-radio-group" + :class="bemClass" + > + <slot></slot> + </view> +</template> + +<script> + import props from './props.js'; + + /** + * radioRroup ������������������ + * @description ���������������������������������������������������������������������������������u-radio������ + * @tutorial https://www.uviewui.com/components/radio.html + * @property {String | Number | Boolean} value ������������ + * @property {Boolean} disabled ������������������radio��������� false ��� + * @property {String} shape ���������������shape-���������circle-������(������ circle ) + * @property {String} activeColor ���������������������������������������Radio��������������� '#2979ff' ��� + * @property {String} inactiveColor ������������������ (������ '#c8c9cc' ) + * @property {String} name ��������� + * @property {String | Number} size ������������������������������px��������� 18 ��� + * @property {String} placement ���������������row-���������column-������ ��������� 'row' ��� + * @property {String} label ������ + * @property {String} labelColor label��������� ��������� '#303133' ��� + * @property {String | Number} labelSize label������������������px������ ��������� 14 ��� + * @property {Boolean} labelDisabled ������������������������������checkbox(������ false ) + * @property {String} iconColor ������������ ��������� '#ffffff' ��� + * @property {String | Number} iconSize ������������������������px ��������� 12 ��� + * @property {Boolean} borderBottom placement���row��������������������������� ��������� false ��� + * @property {String} iconPlacement ������������������������������ ��������� 'left' ��� + * @property {Object} customStyle ������������������������������ + * @event {Function} change ���������radio��������������������������� + * @example <u-radio-group v-model="value"></u-radio-group> + */ + export default { + name: 'u-radio-group', + mixins: [uni.$u.mpMixin, uni.$u.mixin,props], + computed: { + // ������computed���������������������������u-radio��������������������������������������������������������������������������������������������������������������� + // ������������������������������������������������������parentData������������watch���������������������������������������������������������������(u-radio-group) + // ��������������������������������������� + parentData() { + return [this.value, this.disabled, this.inactiveColor, this.activeColor, this.size, this.labelDisabled, this.shape, + this.iconSize, this.borderBottom, this.placement + ] + }, + bemClass() { + // this.bem���������computed������������mixin��� + return this.bem('radio-group', ['placement']) + }, + }, + watch: { + // ��������������������������������������������������������������������������������������� + parentData() { + if (this.children.length) { + this.children.map(child => { + // ���������������(u-radio)���������init���������������������������(������������������������������������������������������������������) + typeof(child.init) === 'function' && child.init() + }) + } + }, + }, + data() { + return { + + } + }, + created() { + this.children = [] + }, + methods: { + // ������������radio��������������������������� + unCheckedOther(childInstance) { + this.children.map(child => { + // ���������radio������������������������������checked������������������ + if (childInstance !== child) { + child.checked = false + } + }) + const { + name + } = childInstance + // ������emit������������������������������v-model������������������ + this.$emit('input', name) + // ������������ + this.$emit('change', name) + }, + } + } +</script> + +<style lang="scss" scoped> + @import "../../libs/css/components.scss"; + + .u-radio-group { + flex: 1; + + &--row { + @include flex; + } + + &--column { + @include flex(column); + } + } +</style> -- Gitblit v1.8.0