This repository was archived by the owner on Mar 27, 2025. It is now read-only.
File tree 3 files changed +40
-30
lines changed
apps/playground/src/components/Comps
packages/bootstrap-vue-next/src/components/BFormRadio
3 files changed +40
-30
lines changed Original file line number Diff line number Diff line change 78
78
</BRow >
79
79
<BRow >
80
80
<BCol >
81
- <h4 >Radio bound to array </h4 >
81
+ <h4 >Radio with primitives </h4 >
82
82
</BCol >
83
83
</BRow >
84
84
<BRow >
85
85
<BCol >
86
- <strong >Select some cars </strong >
86
+ <strong >Select</strong >
87
87
</BCol >
88
88
<BCol >
89
- <strong >Selected cars </strong >
89
+ <strong >Selected</strong >
90
90
</BCol >
91
91
</BRow >
92
92
<BRow >
93
93
<BCol >
94
- <BFormRadio
95
- v-for =" (car, index) in radioAvailableCars"
96
- :key =" index"
97
- v-model =" radioSelectedCars"
98
- :value =" car"
99
- >{{ car }}</BFormRadio
100
- >
94
+ <BFormRadio v-model =" radioPrimitives" :value =" true" >Yes</BFormRadio >
95
+ <BFormRadio v-model =" radioPrimitives" :value =" false" >No</BFormRadio >
101
96
</BCol >
102
97
<BCol >
103
- <ul >
104
- <li v-for =" (car, index) in radioSelectedCars" :key =" index" >{{ car }}</li >
105
- </ul >
98
+ <strong >{{ radioPrimitives }}</strong >
106
99
</BCol >
107
100
</BRow >
108
101
</BContainer >
@@ -117,7 +110,6 @@ const radioRequired = ref(false)
117
110
const radioIndeterminate = ref (false )
118
111
const radioString = ref (' incorrect' )
119
112
const radioPlain = ref (false )
120
- const radioAvailableCars = [' BMW' , ' Mercedes' , ' Toyota' ]
121
- const radioSelectedCars = ref ([])
122
113
const radioSelected = ref ()
114
+ const radioPrimitives = ref (false )
123
115
</script >
Original file line number Diff line number Diff line change 97
97
/>
98
98
</BCol >
99
99
</BRow >
100
+ <BRow >
101
+ <BCol >
102
+ <h4 >Radio with primitives</h4 >
103
+ </BCol >
104
+ </BRow >
105
+ <BRow >
106
+ <BCol >
107
+ <strong >Select</strong >
108
+ </BCol >
109
+ <BCol >
110
+ <strong >Selected</strong >
111
+ </BCol >
112
+ </BRow >
113
+ <BRow >
114
+ <BCol >
115
+ <BFormRadioGroup v-model =" radios.radioPrimitives" >
116
+ <BFormRadio :value =" true" >Yes</BFormRadio >
117
+ <BFormRadio :value =" false" >No</BFormRadio >
118
+ </BFormRadioGroup >
119
+ </BCol >
120
+ <BCol >
121
+ <strong >{{ radios.radioPrimitives }}</strong >
122
+ </BCol >
123
+ </BRow >
100
124
</BContainer >
101
125
</template >
102
126
@@ -135,5 +159,6 @@ const radios = reactive({
135
159
{value: {e: 1 }, text: ' Option E' },
136
160
],
137
161
},
162
+ radioPrimitives: false ,
138
163
})
139
164
</script >
Original file line number Diff line number Diff line change @@ -120,30 +120,23 @@ const localValue = computed({
120
120
? JSON .stringify (parentData .modelValue .value ) === JSON .stringify (props .value )
121
121
: JSON .stringify (modelValue .value ) === JSON .stringify (props .value ),
122
122
set : (newValue : string | boolean | unknown [] | Record <string , unknown > | number | null ) => {
123
- const updateValue = newValue || newValue === ' ' || newValue === 0 ? props .value : false
123
+ const updateValue =
124
+ newValue ||
125
+ newValue === ' ' ||
126
+ newValue === 0 ||
127
+ JSON .stringify (newValue ) === JSON .stringify (props .value )
128
+ ? props .value
129
+ : false
124
130
125
131
emit (' input' , updateValue )
126
132
modelValue .value = updateValue
127
133
nextTick (() => {
128
134
emit (' change' , updateValue )
129
135
})
136
+ if (parentData !== null ) parentData .set (props .value )
130
137
},
131
138
})
132
139
133
- watch (
134
- () => parentData ?.modelValue .value ,
135
- (newValue ) => {
136
- const isEqual = JSON .stringify (newValue ) === JSON .stringify (props .value )
137
- if (isEqual === true ) return
138
- localValue .value = false
139
- }
140
- )
141
-
142
- watch (modelValue , (newValue ) => {
143
- if (parentData === null || newValue === false ) return
144
- parentData .set (props .value )
145
- })
146
-
147
140
const computedRequired = computed (
148
141
() =>
149
142
!! (props .name ?? parentData ?.name .value ) &&
You can’t perform that action at this time.
0 commit comments