WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2023-12-02 c0f7df134cb34328a240be1f792c85cda7250f6c
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
/**
 * CFilterRadio - 筛选项目,单选
 * @author Tevin
 */
 
<template>
    <view
        class="c-filter-radio"
        :class="'type-'+type"
    >
        <view
            class="label"
            v-if="type==='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: {
        type: String,
        label: String,
        options: Array,
        value: [String, Number],
        onChange: Function,
    },
    data() {
        return {};
    },
    methods: {
        handleChange(value) {
            this.onChange(value);
        },
    },
};
</script>