element plus的switch开关通过 :model-value="" 是绑定值,必须等于 active-value
或 inactive-value
,默认为 Boolean
类型
:active-value="2" 是switch 状态为 on
时的值
:inactive-value="1" 是switch的状态为 off
时的值
javascript
<template>
<el-tooltip :content="'Switch value: ' + value" placement="top">
<el-switch
v-model="value"
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
active-value="100"
inactive-value="0"
/>
</el-tooltip>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
const value = ref('100')
</script>