123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <template>
- <view class="tn-radio-group-class tn-radio-group">
- <slot></slot>
- </view>
- </template>
- <script>
- import Emitter from '../../libs/utils/emitter.js'
-
- export default {
- mixins: [ Emitter ],
- name: 'tn-radio-group',
- props: {
-
- value: {
- type: String,
- default: ''
- },
-
- disabled: {
- type: Boolean,
- default: false
- },
-
- disabledLabel: {
- type: Boolean,
- default: false
- },
-
- shape: {
- type: String,
- default: 'circle'
- },
-
- activeColor: {
- type: String,
- default: '#01BEFF'
- },
-
- size: {
- type: Number,
- default: 34
- },
-
- width: {
- type: String,
- default: 'auto'
- },
-
- wrap: {
- type: Boolean,
- default: false
- },
-
- iconSize: {
- type: Number,
- default: 20
- }
- },
- computed: {
-
-
-
- parentData() {
- return [this.value, this.disabled, this.activeColor, this.size, this.disabledLabel, this.shape, this.iconSize, this.width, this.wrap]
- }
- },
- data() {
- return {
-
- }
- },
- watch: {
-
- parentData() {
- if (this.children.length) {
- this.children.map(child => {
-
- typeof(child.updateParentData) === 'function' && child.updateParentData()
- })
- }
- }
- },
- created() {
-
- this.children = []
- },
- methods: {
-
- setValue(value) {
-
- this.children.map(child => {
- if (child.parentData.value !== value) child.parentData.value = ''
- })
-
- this.$emit('input', value)
- this.$emit('change', value)
-
-
- setTimeout(() => {
-
- this.dispatch('tn-form-item', 'on-form-change', value);
- }, 60)
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
-
- .tn-radio-group {
-
- display: inline-flex;
- flex-wrap: wrap;
-
- &::after {
- content: " ";
- display: table;
- clear: both;
- }
- }
-
- </style>
|