This commit is contained in:
张成
2026-03-25 11:28:45 +08:00
parent c3623d4a95
commit b13fabb370
3 changed files with 452 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
<template>
<Switch
:value="value"
<!-- iView / View Design 全局注册为 i-switch勿用 <Switch> 与本组件 name 形成自引用 -->
<i-switch
:value="innerValue"
v-bind="$attrs"
@on-change="handleChange"
/>
@@ -8,12 +9,23 @@
<script>
export default {
name: 'Switch',
name: 'FrameworkSwitch',
props: ['value'],
inheritAttrs: false,
computed: {
innerValue() {
const v = this.value
if (v === true || v === 1 || v === '1' || v === 'true') return true
if (v === false || v === 0 || v === '0' || v === 'false') return false
if (v === '' || v === null || v === undefined) return false
return Boolean(v)
}
},
methods: {
handleChange(checked) {
this.$emit('input', checked)
this.$emit('change', checked)
this.$emit('on-change', checked)
}
}
}