首页 资源列表 文章列表

elementplus el-switch Switch 开关

基础用法#

绑定 v-model 到一个 Boolean 类型的变量。 可以使用 --el-switch-on-color 属性与 --el-switch-off-color 属性来设置开关的背景色。

<template>

 <el-switch v-model="value1" />

 <el-switch

   v-model="value2"

   class="ml-2"

   style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"

 />

</template>


<script lang="ts" setup>

import { ref } from 'vue'


const value1 = ref(true)

const value2 = ref(true)

</script>