<script setup> import mitter from "@/utils/mitter"; import { ref } from "vue"; const props = defineProps({ items: Object, prop: String, }); const value = ref(""); const switchs = () => { mitter.emit("changeVal", { name: props.prop, value: value.value }); }; </script> <template> <el-switch @change="switchs" v-model="value" class="ml-2" :v-bind="items" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" /> </template>