1
- import { defineComponent , h , onMounted , watch , ref } from 'vue'
1
+ import { defineComponent , h } from 'vue'
2
2
import { shape } from 'vue-types'
3
3
4
4
import { Color , Shape } from '../props'
@@ -120,21 +120,6 @@ const CFormCheck = defineComponent({
120
120
'update:modelValue' ,
121
121
] ,
122
122
setup ( props , { attrs, emit, slots } ) {
123
- const checked = ref ( attrs . checked )
124
-
125
- onMounted ( ( ) => {
126
- if ( props . modelValue && typeof props . modelValue === 'boolean' ) {
127
- console . log ( props . modelValue )
128
- }
129
- } )
130
-
131
- watch (
132
- ( ) => props . modelValue ,
133
- ( ) => {
134
- if ( typeof props . modelValue === 'boolean' ) checked . value = props . modelValue
135
- } ,
136
- )
137
-
138
123
const handleChange = ( event : InputEvent ) => {
139
124
const target = event . target as HTMLInputElement
140
125
emit ( 'change' , event )
@@ -143,8 +128,7 @@ const CFormCheck = defineComponent({
143
128
144
129
const formControl = ( ) => {
145
130
return h ( 'input' , {
146
- ...attrs ,
147
- checked : checked . value ,
131
+ checked : props . modelValue ,
148
132
class : [
149
133
props . button ? 'btn-check' : 'form-check-input' ,
150
134
{
@@ -156,6 +140,7 @@ const CFormCheck = defineComponent({
156
140
indeterminate : props . indeterminate ,
157
141
onChange : ( event : InputEvent ) => handleChange ( event ) ,
158
142
type : props . type ,
143
+ ...attrs ,
159
144
} )
160
145
}
161
146
const formLabel = ( ) => {
0 commit comments