修改my-switch组件禁止时透明度变化为可控

This commit is contained in:
YeMingfei666 2024-10-09 17:31:48 +08:00
parent b5eb099c75
commit 77b9ed369a
1 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@
height: height,
borderRadius: `calc(${height} / 2)`,
}" @click.stop="changeSwitch"
:class="{disabled:disabled}"
:class="{disabled:disabled&&openDisabledClass}"
>
<view v-show="!modelValue" class="before" :style="{
left: `calc(${margin} * 2)`,
@ -40,6 +40,10 @@
type:Boolean,
default:false
},
openDisabledClass:{
type:Boolean,
default:true
},
height: {
type: String,
default: '40rpx',
@ -82,10 +86,11 @@
default: false,
},
})
const emits = defineEmits(['update:modelValue', 'change'])
const emits = defineEmits(['update:modelValue', 'change','click'])
// switch
function changeSwitch() {
if(props.disabled){
emits('click')
return
}
let currentVal=props.modelValue