riku
2025-03-18 dd09ea9ab90c89bf5ef78236d02a33bafdcad591
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
<template>
  <!-- <el-button type="primary" class="el-button-custom" size="small">
    
    {{ checkValue ? activeText : inactiveText }}
  </el-button> -->
  <el-checkbox
    v-model="checkValue"
    @change="handleChange"
    border
    size="small"
    >{{ activeText }}</el-checkbox
  >
</template>
<script setup>
import { ref, onMounted, onUnmounted, watch } from 'vue';
 
const props = defineProps({
  defaultValue: {
    type: Boolean
  },
  activeText: {
    type: String,
    default: '开'
  },
  inactiveText: {
    type: String,
    default: '关'
  }
});
 
const emits = defineEmits(['change']);
 
const checkValue = ref(false);
 
watch(
  () => props.defaultValue,
  (nV, oV) => {
    if (nV != oV) {
      checkValue.value = nV;
    }
  },
  { immediate: true }
);
 
function handleChange(value) {
  emits('change', value);
}
</script>
<style scoped>
.el-checkbox {
  --el-checkbox-text-color: white;
  --main-color: #23dad1;
  --el-checkbox-checked-text-color: var(--main-color);
  --el-checkbox-checked-input-border-color: var(--main-color);
  --el-checkbox-checked-bg-color: var(--main-color);
  --el-checkbox-input-border-color-hover: var(--main-color);
 
  --el-checkbox-disabled-checked-input-fill: var(--main-color);
  --el-checkbox-disabled-checked-input-border-color: var(--main-color);
  --el-checkbox-disabled-checked-icon-color: white;
  margin-right: 6px;
  /* height: initial; */
}
 
.el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: var(--el-color-primary);
}
</style>