WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2020-12-01 c4c9a03d3ba029b613d64a6514c132d28636d1c5
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
/**
 * CSwitch
 * @author Tevin
 */
 
<template>
    <view :class="['c-switch', className]">
        <AtSwitch
            :title="itemData.label"
            :checked="itemData.formData[itemData.name]"
            :onChange="evt=>itemData.onChange(evt)"
        />
    </view>
</template>
 
<script>
import { AtSwitch } from 'taro-ui-vue';
import './cSwitch.scss';
 
export default {
    name: 'CSwitch',
    components: { AtSwitch },
    props: {
        itemData: Object,
    },
    data() {
        return {};
    },
    computed: {
        className() {
            let className = '';
            if (this.itemData.required) {
                className += 'c-switch-required ';
            }
            if (this.itemData.error) {
                className += 'c-switch-error ';
            }
            return className;
        },
    },
};
</script>