refactor(switch): support vue3

This commit is contained in:
07akioni 2020-09-28 12:56:21 +08:00
parent 22e75e6169
commit aa61c7c5f6
2 changed files with 8 additions and 6 deletions

View File

@ -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`|`() => {}`||

View File

@ -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()
}
}
}