WebApp【公共组件库】@前端(For Git Submodule)
chensiAb
2024-08-23 9d5803a79aad859e201b94040e369298c7c348b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
 * CFilterRadio - 筛选项目,单选
 * @author Tevin
 */
 
<template>
    <view
        class="c-filter-radio"
        :class="'type-'+place"
    >
        <view
            class="label"
            v-if="place==='item'"
        >{{label}}</view>
        <view class="content">
            <view
                class="c-filter-radio-item"
                v-for="item of options"
                :key="item.value"
                @tap="evt => handleChange(item.value)"
            >
                <view
                    class="c-filter-radio-icon"
                    :class="value===item.value?'checked':''"
                >
                    <AtIcon value="check" />
                </view>
                <view class="c-filter-radio-label">{{item.label || item.name}}</view>
            </view>
        </view>
    </view>
</template>
 
<script>
import Taro from '@tarojs/taro';
import { AtIcon } from 'taro-ui-vue';
import './cFilterRadio.scss';
 
export default {
    name: 'CFilterRadio',
    components: {
        AtIcon,
    },
    props: {
        // 位置类型,bar、item
        place: String,
        // 项名称
        label: String,
        // 项键名
        name: String,
        // 选项
        options: Array,
        // 项值
        value: [String, Number],
        // 变化回调
        onChange: Function,
    },
    data() {
        return {};
    },
    methods: {
        handleChange(value) {
            this.onChange({
                place: this.place,
                name: this.name,
                value,
            });
        },
    },
};
</script>