Vue.js 取消选中单选按钮vuejs
当我更改v型模型数据时,我需要取消选中复选框。如果v型数据为空,则不得选中单选按钮。但有一个问题,数据正在变为null,但单选按钮保持选中状态 有一个单选按钮组件:Vue.js 取消选中单选按钮vuejs,vue.js,Vue.js,当我更改v型模型数据时,我需要取消选中复选框。如果v型数据为空,则不得选中单选按钮。但有一个问题,数据正在变为null,但单选按钮保持选中状态 有一个单选按钮组件: <template lang="pug"> label.radio input.radio__field(type="radio" :name="name" :value="module_value" @change="
<template lang="pug">
label.radio
input.radio__field(type="radio" :name="name" :value="module_value" @change="onChange")
.radio__checker
icon(icon="checked" width="16" height="12")
.radio__text(v-html="text" v-if="text")
</template>
<script>
export default {
data() {
return {
module_value: this.val,
};
},
props: {
name: {
type: String,
required: true,
},
val: {
type: String,
required: true,
},
text: {
type: String,
},
},
watch: {
value(vals) {
this.module_value = vals;
},
},
methods: {
onChange() {
this.$emit("input", this.module_value);
},
},
};
</script>
<style lang="stylus" scoped>
.radio
position relative
display flex
align-items center
cursor pointer
&__checker
size 24px
background-color var(--btn-grey)
margin-right 10px
border 1px solid var(--btn-grey)
tr 0.25
display flex
align-items center
justify-content center
svg
opacity 0
tr 0.25 opacity
&__text
font-size 16px
font-weight 300
&__field
absolute left 12px top 12px
size 1px
opacity 0
&:checked + .radio__checker
background-color var(--btn-blue-bg)
border-color var(--btn-blue-bg)
color var(--btn-blue-text)
svg
opacity 1
&:hover
& ^[0]__checker
border-color var(--btn-blue-bg)
</style>
对于干净的数据,我使用vuex,但没有vuex,我也有同样的问题
current_mode: {
get() {
return this.$store.getters.get_car_mode;
},
set(value) {
this.$store.commit("set_car_mode", value);
this.$store.commit("set_car_complectation", null);
},
},
数据this.$store.commit(“set\u car\u completation”,null)代码>正在更改为null,但单选按钮保持选中状态
current_mode: {
get() {
return this.$store.getters.get_car_mode;
},
set(value) {
this.$store.commit("set_car_mode", value);
this.$store.commit("set_car_complectation", null);
},
},