需求:当开关选择器禁用的时候,点击对应的开关选择器有对应的弹窗展示
官方介绍,看到事件中只有一个参数,并不满足项目的需求

需求:有个数据列表,里面的每一项都有个开关,点击其中的一个开关展示对应的弹窗,需要拿到开关的状态,同时还需要拿到数据项的ID
解决方式:
<template>
<switch :checked="item.checked" color="#A7C83E" :disabled="disabled"style="transform:scale(0.6)" class="inactive-switch" @change="event=>switch1Change(event,item.id)" />
</template>
<script>
const switch1Change = async (event, id) => {isCheckedFlag.value = truehandleArr.value = dataList.value.map(item => {if (item.id == id) {return {...item,checked: event.detail.value}}return item})dataList.value = handleArr.valueapi(id) }
</script>
启发:根据官方的介绍,可以调整为箭头函数返回方法的调用,这样写起来更灵活