mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-11-27 04:09:51 +08:00
refactor(switch): support vue3
This commit is contained in:
parent
22e75e6169
commit
aa61c7c5f6
@ -10,6 +10,6 @@ event
|
||||
|名称|类型|默认值|说明|
|
||||
|-|-|-|-|
|
||||
|disabled|`boolean`|`false`||
|
||||
|modelValue|`boolean`|`false`||
|
||||
|theme|`'light' \| 'dark' \| null \| string`|`null`||
|
||||
|onUpdate:modelValue|`(value: boolean) => any`|`() => {}`||
|
||||
|value|`boolean`|`false`||
|
||||
|on-update:value|`(value: boolean) => any`|`() => {}`||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<div
|
||||
class="n-switch__rail"
|
||||
:class="{
|
||||
'n-switch__rail--active': modelValue,
|
||||
'n-switch__rail--active': value,
|
||||
'n-switch__rail--disabled': disabled
|
||||
}"
|
||||
/>
|
||||
@ -38,7 +38,7 @@ export default {
|
||||
}
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
value: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
@ -47,7 +47,7 @@ export default {
|
||||
default: false
|
||||
},
|
||||
// eslint-disable-next-line vue/prop-name-casing
|
||||
'onUpdate:modelValue': {
|
||||
'onUpdate:value': {
|
||||
type: Function,
|
||||
default: () => {}
|
||||
}
|
||||
@ -55,7 +55,9 @@ export default {
|
||||
methods: {
|
||||
handleClick () {
|
||||
if (!this.disabled) {
|
||||
this['onUpdate:modelValue'](!this.modelValue)
|
||||
this['onUpdate:value'](!this.value)
|
||||
this.__triggerFormInput()
|
||||
this.__triggerFormChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user